Corda 5 Developer Preview 2 is now available.

JSON

Corda provides a module that extends the popular Jackson serialization engine. Jackson can serialize to and from JSON, and formats such as YAML and XML. Jackson is very modular - you can use several plugins to extend its functionality. See the Jackson home page .

To gain support for JSON serialization of common Corda data types:

  1. Include a dependency on net.corda:jackson:XXX in your Gradle or Maven build file, where XXX is the Corda version you are targeting (0.9 for M9, for instance).
  2. Obtain a Jackson ObjectMapper instance configured using the JacksonSupport.createNonRpcMapper() method.

You can use variations of this method to get alternative Jacksons configurations. For example, if you have an RPC connection to the node (see Interacting with the node ) then your JSON ObjectMapper can resolve identities found in objects. The ObjectMapper provides a straightforward, flexible way to parse and generate JSON response objects.

For the full API details, see the:

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.