Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Add ultility to construct JsonStructure from raw JSON string #69

Open
glassfishrobot opened this issue Apr 4, 2015 · 6 comments
Open

Comments

@glassfishrobot
Copy link
Contributor

Currently, JsonArrayBuilder and JsonObjectBuilder can be used to create JSON object models from scratch. However, the process is cumbersome and verbose. There should be an easier way for doing this.

I am proposing something like the following:

JsonArray a = JsonUtil.getArray(
    "[{'abc': 'xyz', 'ss': 1234}, {'m\\'n': 'l\"m'}]");

Note that I'm using single quotes for JSON strings, otherwise I'll have lots of " as required in Java. I am not proposing allowing single quotes for JSON string (which is not allowed in JSON) in general. This utility will need to convert ' to " before sending it to JsonReader.

Note also \ is used to allow ' or " inside the JSON string, but this is just some details that we should not worry for now.

Such utility will be very useful in writing JSON tests. But it should be useful to JSON users.

@glassfishrobot
Copy link
Contributor Author

Reported by kchung

@glassfishrobot
Copy link
Contributor Author

Was assigned to kchung

@glassfishrobot
Copy link
Contributor Author

mitemitreski said:
Single quotes are great idea but we need to make sure somehow that it is clear that this is intended as a helper only and not standards derailing.

Is JavaDoc enough for this ?

@glassfishrobot
Copy link
Contributor Author

kchung said:
We need to be clear that single quotes can only be used in this method. We'll have to do our best in the javadocs, since it the only thing we have for the spec.

@glassfishrobot
Copy link
Contributor Author

@m0mus said:
I am not sure that we need it.

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JSON_PROCESSING_SPEC-69

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant