https://github.com/vavr-io/vavr-gson
Gson datatype module for Vavr
https://github.com/vavr-io/vavr-gson
gson immutable-collections persistent-collections vavr
Last synced: 14 days ago
JSON representation
Gson datatype module for Vavr
- Host: GitHub
- URL: https://github.com/vavr-io/vavr-gson
- Owner: vavr-io
- License: apache-2.0
- Created: 2017-03-30T11:08:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-11-20T16:12:37.000Z (over 4 years ago)
- Last Synced: 2023-08-12T16:10:41.898Z (almost 2 years ago)
- Topics: gson, immutable-collections, persistent-collections, vavr
- Language: Java
- Homepage:
- Size: 178 KB
- Stars: 17
- Watchers: 7
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://maven-badges.herokuapp.com/maven-central/io.vavr/vavr-gson)
[](https://travis-ci.org/vavr-io/vavr-gson)
[](https://codecov.io/github/vavr-io/vavr-gson?branch=master)
[](https://gitter.im/vavr-io/vavr)# vavr-gson
A set of GSON serialiser/deserialisers for [Vavr](http://vavr.io/) library## Usage
### Maven
```xml
io.vavr
vavr-gson
0.10.2```
### Gradle
```groovy
compile("io.vavr:vavr-gson:0.10.2")
```### Registering converters
```java
GsonBuilder builder = new GsonBuilder();
VavrGson.registerAll(builder);
gson = builder.create();
```### Serialization/deserialization
```java
String json = gson.toJson(List.of(List.of(1)));
// = [[1]]
Object restored1 = gson.fromJson(json, List.class);
// = List([1])
Type type = new TypeToken>>(){}.getType();
Object restored2 = gson.fromJson(json, type);
// = List(List(1))
```## Using Developer Versions
Developer versions can be found [here](https://oss.sonatype.org/content/repositories/snapshots/io/vavr/vavr-gson).
### Maven
```xml
io.vavr
vavr-gson
1.0.0-SNAPSHOT```
Ensure that your `~/.m2/settings.xml` contains the following:
```xml
allow-snapshots
true
snapshots-repo
https://oss.sonatype.org/content/repositories/snapshots
false
true
```
### Gradle
```groovy
compile("io.vavr:vavr-gson:1.0.0-SNAPSHOT")
```Ensure that your `build.gradle` contains the following:
```groovy
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}