An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.vavr/vavr-gson/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.vavr/vavr-gson)
[![Build Status](https://travis-ci.org/vavr-io/vavr-gson.svg?branch=master)](https://travis-ci.org/vavr-io/vavr-gson)
[![Coverage Status](https://codecov.io/github/vavr-io/vavr-gson/coverage.svg?branch=master)](https://codecov.io/github/vavr-io/vavr-gson?branch=master)
[![Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](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"
}
}