Oson

Java object to Json converter, to serialize Java object to Json string, and deserialize Json string to Java Object

License

License

Categories

Categories

JSON Data
GroupId

GroupId

ca.oson.json
ArtifactId

ArtifactId

oson
Last Version

Last Version

1.0.13
Release Date

Release Date

Type

Type

jar
Description

Description

Oson
Java object to Json converter, to serialize Java object to Json string, and deserialize Json string to Java Object
Project URL

Project URL

https://github.com/osonus/oson
Project Organization

Project Organization

oson.ca
Source Code Management

Source Code Management

https://github.com/osonus/oson

Download oson

How to add to project

<!-- https://jarcasting.com/artifacts/ca.oson.json/oson/ -->
<dependency>
    <groupId>ca.oson.json</groupId>
    <artifactId>oson</artifactId>
    <version>1.0.13</version>
</dependency>
// https://jarcasting.com/artifacts/ca.oson.json/oson/
implementation 'ca.oson.json:oson:1.0.13'
// https://jarcasting.com/artifacts/ca.oson.json/oson/
implementation ("ca.oson.json:oson:1.0.13")
'ca.oson.json:oson:jar:1.0.13'
<dependency org="ca.oson.json" name="oson" rev="1.0.13">
  <artifact name="oson" type="jar" />
</dependency>
@Grapes(
@Grab(group='ca.oson.json', module='oson', version='1.0.13')
)
libraryDependencies += "ca.oson.json" % "oson" % "1.0.13"
[ca.oson.json/oson "1.0.13"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

oson

Oson means O(bject) Json, and pronounces as awesome. It is a Java serialization/deserialization library that can convert Java Objects into JSON and back.

This library implements its own Java to/from Json processor, and provides a common interface to Google's Gson and Jackson's ObjectMapper.

Just like annotation and lambda expressions make Java look like a functional language, these features make Oson as a flexible choice of Java-Json processors.

###Oson Goals

  • Convert arbitray Java Object to Json data and back
  • Provide a common interface to Gson and ObjectMapper
  • Support major set of Json annotations: including com.fasterxml.jackson, com.google.gson, org.codehaus.jackson, javax.persistence, javax.validation (JPA), in addition to its own ca.oson.json annotation
  • Allow 3 level control of name and value conversions: global, class-level, and field level
  • Allow these conversions to be either annotation-oriented, or Java oriented, or both
  • Allow well-formatted JSON output: any indentation, any depth, as far as object linkage goes, without redundancy
  • Functions of lambda expressions are added to the serialization and deserialization processes, allowing easy value transformation
  • OsonAssert.assertEquals methods are implemented for JUnit testing, to compare Json string, JSONObject and Java objects
  • OsonMerge is implemented to merge Json strings, JSONObject and Java objects, with flexible configuration options
  • OsonPath is on the way, to implement XML XPath-similar features, and with queries easier to use
  • OsonConvert is on the way, to create custom Java object and classes from Json input

###Oson Documentation

  • Oson API: Javadocs for the current Oson release
  • Oson user guide: This guide contains examples on how to use Oson in your code.

###Using Oson with Maven To use Oson with Maven2/3, you can use the Oson version available in Maven Central by adding the following dependency:

<dependencies>
	<!-- https://mvnrepository.com/artifact/ca.oson.json/oson -->
	<dependency>
	    <groupId>ca.oson.json</groupId>
	    <artifactId>oson</artifactId>
	    <version>1.0.11</version>
	</dependency>
</dependencies>

###Usage

		Oson oson = new Oson();
		
		String json = "[\"Hello World\",\"\"]";

		Set set = oson.deserialize(json, LinkedHashSet.class);
		assertEquals(LinkedHashSet.class, set.getClass());
		assertEquals(json, oson.serialize(set));
		
		set = oson.asGson().fromJson(json, LinkedHashSet.class);
		assertEquals(LinkedHashSet.class, set.getClass());
		assertEquals(json, oson.toJson(set));
		
		set = oson.asJackson().readValue(json, LinkedHashSet.class);
		assertEquals(LinkedHashSet.class, set.getClass());
		assertEquals(json, oson.writeValueAsString(set));

###License

Oson is released under the Apache 2.0 license.

Copyright 2016 oson.ca

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.1
1.0.0