I am using GSON to parse a Java bean and pass the JSON string to some javascript. There is an item with sensitive data included in the bean, its not a major security risk, but something i’d rather not be able to be seen in the browser by anyone with a tool such as firebug. This particular variable, I don’t need to use in the javascript code.
Is there a way to just skip it when parsing the JSON string from the bean and not include it in the string at all.
Maybe I need to create the JSON string and then remove it before I send back to the client?
I don’t know GSON particularly, so they may have an option for this. If I were them, I would skip transient fields.
The easiest thing however if your bean is not complex is to clone/copy it and then remove the sensitive data from the bean in java. That’s got to be easier than trying to edit the JSON after the fact.