Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Need a common supertype for JsonArray and JsonObject. Otherwise, the object model API
      has two "top level" types and that looks odd. A common type would make it easy to pass
      JSON text around. The changes would be:

      public interface JsonText {
      }

      public interface JsonArray extends JsonValue, JsonText {
      }

      public interface JsonObject extends JsonValue, JsonText {
      }

      public class JsonBuilder {

      public static interface JsonBuildable<T extends JsonText>

      { ..}

      ...
      }

      public class JsonWriter implements Closeable {
      public void write(JsonText value)

      { ... }
      }

      public class JsonReader implements Closeable {
      public JsonText read() { ... }

      }

      Can also use JsonDocument instead of JsonText, but JsonText is preferred as it is
      used by grammar.

      Perhaps, we also need to add START_TEXT, END_TEXT parser events.

        Activity

        Hide
        jhorstmann added a comment -

        Isn't JsonValue already the common supertype?

        From the grammar in the rfc, json text would be the serialized form of an object or array. I think this distinction between serialized form and object model should be made clear in the api, as that is not always the case with other json libs.

        The only common property of object and array would perhaps be a 'size' property. If you think another interface would be useful then I would suggest a name like JsonContainer or JsonStructure. The term structure also appears in the rfc, but might be mistaken for a C struct, which is more like a json object.

        Show
        jhorstmann added a comment - Isn't JsonValue already the common supertype? From the grammar in the rfc, json text would be the serialized form of an object or array. I think this distinction between serialized form and object model should be made clear in the api, as that is not always the case with other json libs. The only common property of object and array would perhaps be a 'size' property. If you think another interface would be useful then I would suggest a name like JsonContainer or JsonStructure. The term structure also appears in the rfc, but might be mistaken for a C struct, which is more like a json object.
        Hide
        jitu added a comment -

        JsonValue is a supertype of JsonArray/JsonObject but that also includes other values like JsonString, JsonNumber etc. Hence the new type.

        Your have a point about serialized form and the use of JsonText etc. Simiarly, some suggested to use JsonMap/JsonList instead of JsonObject/JsonArray(when I experimented with this, this renaming is not coming out well).

        Show
        jitu added a comment - JsonValue is a supertype of JsonArray/JsonObject but that also includes other values like JsonString, JsonNumber etc. Hence the new type. Your have a point about serialized form and the use of JsonText etc. Simiarly, some suggested to use JsonMap/JsonList instead of JsonObject/JsonArray(when I experimented with this, this renaming is not coming out well).
        Hide
        jitu added a comment -

        Let me use JsonStructure for now. If we find a better name, we will use it.

        Show
        jitu added a comment - Let me use JsonStructure for now. If we find a better name, we will use it.

          People

          • Assignee:
            jitu
            Reporter:
            jitu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: