Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Creating json data

Drew Koszewnik edited this page Nov 15, 2013 · 2 revisions

It’s easy to create JSON data from objects with Zeno. Let’s look at a code example:

In this example, we’ve instantiated a JsonSerializationFramework with our SerializerFactory, and then passed it the type name (as defined in our NFTypeSerializer), and the object. The result of this call is as follows:

{
  "blist" : {
    "list" : [ {
      "bInt" : 100,
      "bString" : "one hundred"
    }, {
      "bInt" : 2000,
      "bString" : "two thousand"
    } ]
  },
  "c" : {
    "cLong" : 9223372036854775807,
    "cBytes" : "AQIDBAU="
  },
  "intVal" : 1
}

To deserialize a json representation of our object, we can pass a String into the JsonSerializationFramework:

Like all Zeno framework implementations, we can use any object in our model heirarchy with the JsonSerializationFramework. We are not constrained to just top level objects:

This produces the following:

{
  "bInt" : 50,
  "bString" : "fifty"
}

Clone this wiki locally