java - Converting Strings to booleans when converting XML to JSON -


This block of code essentially takes a JAXB object and converts it to JSONObject

  StringWriter StringWriter = new stringwriter (); Marshaller.marshal (jaxbObj, stringWriter); Try {JSONObject jsonObject = XML.toJSONObject (stringWriter.toString ()); . Resp.getOutputStream () write (jsonObject.toString (2) .getBytes ()); } Hold (JasonXExtension) {New Service Exception ("Jasonson could not be parsed", e); }  

Unfortunately, this change is not a string like "true" in a boolean, it says, preventing a person with a bad front from doing so.

I think I want to map values ​​in JSONObject in any way, calling each one I think is a better way any ideas?

Well, JACAB will not produce JSON to start itself, so you are using Apart from this (maybe using jerseys), maybe there is something in the package in question.

But why try to do this with the org.json object? Just use the regular Java Bean with the expected type, make sure that any input you have is no magic, just the clear code.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -