[JSON_PROCESSING_SPEC-5] Super type for JsonArray and JsonObject Created: 13/Jun/12  Updated: 03/Dec/12  Resolved: 01/Aug/12

Status: Closed
Project: json-processing-spec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: jitu Assignee: jitu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


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.

Comment by jhorstmann [ 13/Jun/12 ]

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.

Comment by jitu [ 13/Jun/12 ]

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).

Comment by jitu [ 01/Aug/12 ]

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

Generated at Mon Sep 26 14:22:37 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.