Skip to content

vavr-io/vavr-gson

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Maven Central Build Status Coverage Status Gitter Chat

vavr-gson

A set of GSON serialiser/deserialisers for Vavr library

Usage

Maven

<dependency>
  <groupId>io.vavr</groupId>
  <artifactId>vavr-gson</artifactId>
  <version>0.10.2</version>
</dependency>

Gradle

compile("io.vavr:vavr-gson:0.10.2")

Registering converters

  GsonBuilder builder = new GsonBuilder();
  VavrGson.registerAll(builder);
  gson = builder.create();

Serialization/deserialization

  String json = gson.toJson(List.of(List.of(1)));
  // = [[1]]
  Object restored1 = gson.fromJson(json, List.class);
  // = List([1])
  Type type = new TypeToken<List<List<Integer>>>(){}.getType();
  Object restored2 = gson.fromJson(json, type);
  // = List(List(1))

Using Developer Versions

Developer versions can be found here.

Maven

<dependency>
  <groupId>io.vavr</groupId>
  <artifactId>vavr-gson</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>

Ensure that your ~/.m2/settings.xml contains the following:

<profiles>
    <profile>
        <id>allow-snapshots</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>snapshots-repo</id>
                <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

Gradle

compile("io.vavr:vavr-gson:1.0.0-SNAPSHOT")

Ensure that your build.gradle contains the following:

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}