Package playn.core

Interface Json


public interface Json
PlayN JSON parsing and serialization interface.
  • Method Details

    • createArray

      Json.Array createArray()
      Creates an new, empty Json.Array.
    • createObject

      Json.Object createObject()
      Creates an new, empty Json.Object.
    • isArray

      boolean isArray(Object o)
      Determines if the given object is a JSON Json.Array.
    • isObject

      boolean isObject(Object o)
      Determines if the given object is a JSON Json.Object.
    • newWriter

      Json.Writer newWriter()
      Creates a new Json.Writer, which can be used to serialize data into the JSON format.
      
       // An example of using the JSON writer interface.
       String jsonString = json.newWriter()
           .object()
               .value("x", 10)
               .value("y", 10)
               .object("nestedObject")
                    .value("id", "xyz123")
               .end()
               .array("nestedArray")
                   .value(1)
                   .value(2)
                   .value(3)
                   .value(4)
                   .value(5)
               .end()
           .end()
       .done();
      
       // Produces:
       {
         'x': 10,
         'y': 10,
         'nestedObject': {
           'id': 'xyz123'
         },
         'nestedArray': [
           1, 2, 3, 4, 5
         ]
       }
       
    • parse

      Json.Object parse(String json) throws playn.core.json.JsonParserException
      Parses the given JSON string into an Json.Object that can be dynamically introspected.
      Throws:
      playn.core.json.JsonParserException
    • parseArray

      Json.Array parseArray(String json) throws playn.core.json.JsonParserException
      Parses the given JSON string into an Json.Array that can be dynamically introspected.
      Throws:
      playn.core.json.JsonParserException