Coder Social home page Coder Social logo

derjochen / json4j Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 78 KB

API project for JSON entity deserialization and serialization and two adapters for external projects. In a current project I need an abstraction layer for JSON entity operations. Since JSR 367 (Java API for JSON Binding (JSON-B)) is still far away, I created this project.

License: GNU General Public License v2.0

Java 100.00%

json4j's Introduction

json4j

Abstraction layer project for JSON entity deserialization and serialization and two adapters for external projects.

Motivation

In a current project I need an abstraction layer for JSON entity operations. Since JSR 367 (Java API for JSON Binding (JSON-B)) is still far away, I created this project.

But why?

The project where this is needed itself is a library. So it should be easily reusable and bring no extra baggage.

Say you have a project and use library A for JSON entity operations. Now you add a new dependency to a library for a REST service you want to use - and this library depends on JSON entity library B. You end up with two dependencies who do exactly the same thing. Who needs that?

If the REST library would just depend on an API project you could use an existing adapter implementation for library A or quickly write one yourself. Problem solved.

Usage

Since this project is currently intended for my java-lib-for-wunderlist project, I keep the usage chapter very short. It basicly works like log4j or slf4j. You depend on the facade project (see Maven) and only use the JSONBindingService interface for JSON-entity-conversion.

The field initialization looks like this:

private JSONBindingService jsonBindingService = JSONBindingServiceFactory.create();

During compile time this code is perfectly fine. When running the program a concrete implementation of the JSONBindingService interface is needed. For that you additionally depend on an adapter implementation (e.g. json4j-gson). In your library project you do not want to have a compile dependency to an adapter implementation, but with a test dependency you actually can run and test your code.

If you have multiple adapter projects in your classpath you can select a specific one by setting the Java system property jochor.servicefactory.de.jochor.lib.json4j.StaticJSONBindingBinder to the full qualified name of the service class.

System.setProperty("jochor.servicefactory.de.jochor.lib.json4j.StaticJSONBindingBinder", "de.jochor.lib.json4j.gson.JSONBindingServiceGson");

Normally this is only necessary if you need different implementation during testing and runtime.

Maven

Dependency Tag

Facade project

<dependency>
	<groupId>de.jochor.lib.json</groupId>
	<artifactId>json4j</artifactId>
	<version>0.3.2</version>
</dependency>

Adapter implementation for GSON v2.3.1

<dependency>
	<groupId>de.jochor.lib.json</groupId>
	<artifactId>json4j-gson</artifactId>
	<version>0.3.2</version>
</dependency>

Adapter implementation for Jackson v2.6.1

<dependency>
	<groupId>de.jochor.lib.json</groupId>
	<artifactId>json4j-gson</artifactId>
	<version>0.3.2</version>
</dependency>

Repository Tag

Releases

<repository>
	<id>jochor-public-releases</id>
	<url>http://maven.jochor.de/content/repositories/public-releases/</url>
</repository>

Snapshots

<repository>
	<id>jochor-public-releases</id>
	<url>http://maven.jochor.de/content/repositories/public-snapshots/</url>
</repository>

json4j's People

Contributors

derjochen avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

json4j's Issues

Add jUnit tests

Add tests to check and test the current features and limitations. Try to make it very generic, so that the tests work for every implementation without changing a thing.

Embed the classes from service-factory

Embed the classes from service-factory during the build process in the project jar. Otherwise there might be version conflicts in using applications for the service-factory jar.

Prepare and release stable version 0.1.0

Check feature and code quality for the first release. Document how to use the library (Maven repository and dependency tags). Increment the version - and push.

Make implementation selectable

Adapt to changes in the service-factory project. The static binder has to have a method to return the full qualified name of its implementation. This is used to make an implementation selectable by setting a system property.

Adapt to changed init process

Adapt to changed init process of the service-builder project. The basis is no longer a classpath scan but one specific class with a static create() method.

Add JaveDoc and small HowTo

Check the existence and quality of the JavaDoc. Extend where needed.
Add a small HowTo, maybe with an example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.