Serialize output to JSON in Java#64
Merged
nikhilm merged 3 commits intoiron-io:masterfrom Nov 3, 2016
seiflotfy:java-update
Merged
Serialize output to JSON in Java#64nikhilm merged 3 commits intoiron-io:masterfrom seiflotfy:java-update
nikhilm merged 3 commits intoiron-io:masterfrom
seiflotfy:java-update
Conversation
nikhilm
approved these changes
Nov 2, 2016
| if (!processed) { | ||
| System.err.println(String.format("Handler %s with simple, POJO, or IO(input/output) types not found", handlerName)); | ||
| } | ||
| String jsonInString = ClassTypeHelper.gson.toJson(result); |
Contributor
There was a problem hiding this comment.
Not 100% sure about this lib's behavior. Is it going to throw an exception or something ifthe result is not serializable? Do you want to just wrap a try catch around it?
nikhilm
reviewed
Nov 3, 2016
| System.out.println(jsonInString); | ||
| } | ||
| catch (Exception e) { | ||
| System.out.println("{\"error\": \"" + e + "\"}"); |
Contributor
There was a problem hiding this comment.
It is possible for the exception message to have " double quotes, in which case the resulting JSON will be invalid. What you want to do is replace e with gson.toJson(e.toString())?
nikhilm
approved these changes
Nov 3, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.