-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence of adding a JsonArrayBuilder into a JsonObjectBuilder interferes in the final result #6
Comments
@glassfishrobot Commented |
@glassfishrobot Commented |
@keilw Commented |
@keilw Commented |
|
Same question for Ideally, regardless of any change (or not) in the implementation, the JavaDoc for these methods should be explicit about when the sub-builder's |
While creating some Json content using the Object Model API, I realised that the sequence of adding a JsonArrayBuilder into a JsonObjectBuilder interferes in the final result. The following code won't include the categories in the resulting Json because the line, indicated with an arrow, adds the JsonArrayBuilder to the JsonObjectBuilder before JsonArrayBuilder is loaded with data :
To work around with the problem, I had to move that highlighted line to after the iteration:
Apparently, the build is performed right away, while data is added to those builder objects. In fact, it should be built only when the method build() is finally invoked. In both examples, it always happen when all data is added to the builders and it is time to build the final JsonObject model. Therefore, both examples above should work normally.
Environment
JDK 1.7, Glassfish 3.1.2.2, Jersey 1.8
Affected Versions
[1.0.3]
The text was updated successfully, but these errors were encountered: