JSON

Corda provides a module that extends the popular Jackson serialisation engine. Jackson is often used to serialise to and from JSON, but also supports other formats such as YaML and XML. Jackson is itself very modular and has a variety of plugins that extend its functionality. You can learn more at the Jackson home page.

To gain support for JSON serialisation of common Corda data types, include a dependency on net.corda:jackson:XXX in your Gradle or Maven build file, where XXX is of course the Corda version you are targeting (0.9 for M9, for instance). Then you can obtain a Jackson ObjectMapper instance configured for use using the JacksonSupport.createNonRpcMapper() method. There are variants of this method for obtaining Jackson’s configured in other ways: if you have an RPC connection to the node (see “Interacting with a node”) then your JSON mapper can resolve identities found in objects.

The API is described in detail here:

import net.corda.jackson.JacksonSupport

val mapper = JacksonSupport.createNonRpcMapper()
val json = mapper.writeValueAsString(myCordaState)  // myCordaState can be any object.
import net.corda.jackson.JacksonSupport

ObjectMapper mapper = JacksonSupport.createNonRpcMapper()
String json = mapper.writeValueAsString(myCordaState)  // myCordaState can be any object.

Was this page helpful?

Thanks for your feedback!

Chat with us

Chat with us on our #docs channel on slack. You can also join a lot of other slack channels there and have access to 1-on-1 communication with members of the R3 team and the online community.

Propose documentation improvements directly

Help us to improve the docs by contributing directly. It's simple - just fork this repository and raise a PR of your own - R3's Technical Writers will review it and apply the relevant suggestions.

We're sorry this page wasn't helpful. Let us know how we can make it better!

Chat with us

Chat with us on our #docs channel on slack. You can also join a lot of other slack channels there and have access to 1-on-1 communication with members of the R3 team and the online community.

Create an issue

Create a new GitHub issue in this repository - submit technical feedback, draw attention to a potential documentation bug, or share ideas for improvement and general feedback.

Propose documentation improvements directly

Help us to improve the docs by contributing directly. It's simple - just fork this repository and raise a PR of your own - R3's Technical Writers will review it and apply the relevant suggestions.