Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bazaarvoice/rison
Rison encoder and decoder for the Jackson streaming JSON processor
https://github.com/bazaarvoice/rison
Last synced: 2 months ago
JSON representation
Rison encoder and decoder for the Jackson streaming JSON processor
- Host: GitHub
- URL: https://github.com/bazaarvoice/rison
- Owner: bazaarvoice
- License: apache-2.0
- Created: 2012-05-23T23:11:22.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2022-12-21T02:35:26.000Z (about 2 years ago)
- Last Synced: 2023-07-26T21:20:33.539Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 139 KB
- Stars: 16
- Watchers: 53
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Rison Parser and Generator for Jackson
======================================A plugin for the [Jackson streaming JSON processor v2.10.x](http://wiki.fasterxml.com/JacksonHome) that adds
support for reading and writing JSON objects in the [Rison](http://mjtemplate.org/examples/rison.html)
serialization format.
Support for Jackson:
- [v2.9.x](https://github.com/bazaarvoice/rison/tree/rison-2.9.9)
- [v2.6.x](https://github.com/bazaarvoice/rison/tree/rison-2.6.3)
- [v2.1.x](https://github.com/bazaarvoice/rison/tree/rison-2.1.1)
- [v2.0.x](https://github.com/bazaarvoice/rison/tree/rison-2.0.1)
- [v1.9.x](https://github.com/bazaarvoice/rison/tree/rison-1.2)
is also available.Rison expresses the exact same data structures as JSON, but is much more compact and readable than JSON
when encoded in a URI.See https://github.com/Nanonid/rison for more information about Rison.
Usage
-----In your code, create a `RisonFactory` instead of a `JsonFactory`. Then read and write objects just
as you do regular JSON objects. All the Jackson mapper facilities are available with Rison.```java
import com.bazaarvoice.jackson.rison.RisonFactory;ObjectMapper RISON = new ObjectMapper(new RisonFactory());
String string = "(a:0,b:foo,c:'23skidoo')";
Map map = RISON.readValue(string, Map.class);
...
RISON.writeValueAsString(map);
```O-Rison
-------If you know the value you wish to serialize is always an object, you can configure the `RisonFactory`
to omit the containing `(` and `)` characters.```java
ObjectMapper O_RISON = new ObjectMapper(new RisonFactory().
enable(RisonGenerator.Feature.O_RISON).
enable(RisonParser.Feature.O_RISON));String string = "a:0,b:foo,c:'23skidoo'";
Map map = O_RISON.readValue(string, Map.class);
...
System.out.println(O_RISON.writeValueAsString(map));
```A-Rison
-------If you know the value you wish to serialize is always an array, you can configure the `RisonFactory`
to omit the containing `!(` and `)` characters.```java
ObjectMapper A_RISON = new ObjectMapper(new RisonFactory().
enable(RisonGenerator.Feature.A_RISON).
enable(RisonParser.Feature.A_RISON));String string = "item1,item2,item3";
List list = A_RISON.readValue(string, List.class);
...
System.out.println(A_RISON.writeValueAsString(list));
```Other Implementations
---------------------
See the [Rison](http://mjtemplate.org/examples/rison.html) page for implementations in JavaScript,
Python and Ruby.