Skip to content

balajeetm/json-mystique

Repository files navigation

Build Status

Json Mystique

The umbrella of utilities for Json Manipulation, Json Conversion and Json transformation in Java.
It is vaguely similar to lodash's object manipulation capabilities but adds a lot more punch to it.

Json mystique ships a set of libraries written in and for Java, useful for json manipulation & transformation

  • Json Manipulation
    The library exposes simple get, set and default methods for json manipulation.
    Eg. JsonElement json = { 'a': [{ 'b': { 'c': 3 } }] };
    jsonLever.get(json, 'a.0.b.c');
    // => 3
    
    Refer JsonLever, GsonConvertor, JacksonConvertor, JsonQuery and JsonComparator for more details.
  • Json Transformation
    The library takes an input json as a string or JsonElement and transforms the same to a json string or JsonElement.
    The transformation is performed via a ruleSet file that specifies the mappings in a json format.
    Refer JsonMystique for more details.

Features and Primary Use Cases

  • The library is useful for simple Json representation, access and manipulation in Java
    Eg. JsonElement json = { 'a': [{ 'b': { 'c': 3 } }] };
    jsonLever.get(json, 'a.0.b.c');
    // => 3
    jsonLever.get(object, ["a", "0", "b", "c"]);
    // => 3
    jsonLever.get(object, "a.b.c", "default");
    // => "default"
    
    Refer JsonLever for more details
  • The library is useful for transforming from one json to another, even when the input and output jsons are non identical
    • Multiple fields from the input can be operated on to map to a single field in the output
    • Custom converters can be easily plugged to handle custom domain logic Refer JsonMystique for more details.
  • The library exposes a standard interface for converting POJO to json and vice versa
    • The standard interface is implemented in Gson via GsonConvertor and
    • Jackson via JacksonConvertor
  • The library is useful for getting subset or projections of a json object.
    Refer JsonLever for more details
  • The library is useful for comparing two jsons
    • Compare if two jsons are identical
    • Compare if one json is a subset of another Refer JsonComparator for more details
  • The library exposes a query interface on a json, to perform various 'sql'-like queries on a json and select relevant fields from it.
    Refer JsonQuery for more details

Dependencies

The actual versions can be found in the pom file

Maven Download

Json Mystique and all its libraries download at Maven Central.
The different library utils, their capabilities & their maven dependency snippets are detailed below:

Json Mystique - Native Library


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>json-mystique</artifactId>
    <version>2.5.3</version>
</dependency>

NOTE
There are three variants of JsonMystique.
The 1.x.x and 0.x.x versions have reached EOL. 2.x.x is the only active version as of now

2.x.x - Standalone json transformation utility
1.x.x - Parallel processing json transformation utility
0.x.x - Sequential processing json transformation utility

NOTE 2.2.x onwards supports Spring Boot 2.1.X

NOTE
2.x.x is the only supported version currently since the parallel processing logic is mainstream. The other versions (0.x.x and 1.x.x) have been deprecated.
It is highly recommended and suggested, to only use the 2.x.x versions of Mystique.
Please raise issues, for support if any, on earlier versions.

Json Mystique - Spring Boot Starter


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>json-mystique-starter</artifactId>
    <version>2.5.3</version>
</dependency>

The custom spring-boot-starter for JsonMystique. Autoconfigures all necessary beans and seamlessly integrates with Spring's RestControllers and Jackson libraries.

The json mystique's spring boot starter autoconfigures the json mystique environment appropriately, creating all the necessary beans. Its primary features are

  • Configures the simple Jackson Json Convertor as a bean
  • Configures the simple Gson Json Convertor as a bean
  • Configures Jackson Object Mapper with the ability to serialise and deserialise Gson Objects (JsonElement)
  • Configures JsonMystique with its appropriate turns as a bean
  • If Spring-web is in the classpath, it connfigures a RestTemplate with the ability to serialise and deserialise Gson Objects (JsonElement)
  • Automatically registers custom Json Mystique MystTurns with JsonMystique

For more details refer the usage guide or the sample projects for usage

Json Mystique - Gson Utilities


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>gson-utils</artifactId>
    <version>2.5.3</version>
</dependency>

The json mystique gson utility library provides a set of utility classes to operate on manipulate, access and operate on json objects. All the utilities are standalone instances that can be accessed via getInstance() and use right away.
The utility classes are

  • Json Lever - Utility to operate on raw json objects. Exposes simplified lodash like object manipulation interfaces and a type safe use of the Gson library. Allows deep and shallow merge & clone of jsons
  • Gson Convertor
    • Utility for POJO Object Model Mapping. Provides a simplified interface to convert to and from a json
  • Json Comparator
    • Utility to compare two jsons
  • Json Query - Utility to perform sql-like queries on a json element to select appropriate fields from a json (can be an object or an array)
  • Json Builder - Builder utility to build jsons elements so that the properties can be added in a chained fashion

Json Mystique - Jackson Utilities


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>jackson-utils</artifactId>
    <version>2.5.3</version>
</dependency>

The json mystique jackson utility library provides a set of utility classes, implemented using jackson, to operate on raw json objects and serialise deserialise POJOs. The utility classes are

Spring Boot 2 Support

JsonMystique completely supports Spring Boot 2.

json-mystique


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>json-mystique</artifactId>
    <version>2.5.3</version>
</dependency>

json-mystique-starter


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>json-mystique-starter</artifactId>
    <version>2.5.3</version>
</dependency>

gson-utils


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>gson-utils</artifactId>
    <version>2.5.3</version>
</dependency>

jackson-utils


<dependency>
    <groupId>com.balajeetm.mystique</groupId>
    <artifactId>jackson-utils</artifactId>
    <version>2.5.3</version>
</dependency>

Documentation

For detailed documentation, refer the documentation index
For more information on the usage and detailed usage guides, refer the documentation home

About

Utility for Json Conversion and json transformation in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •