#126 Xml -> Json converter is missing attribute 'type'

open-invalid
nobody
None
5
2012-03-24
2012-03-23
Anonymous
No

I'm pretty new to json-lib, but I'm already extremely happy with how well it converts XML to JSON. However, I'm seeing an issue with the output with regard to one particular attribute.

An example is below. The JSON output is missing the 'type' attribute. I'm not sure if this is a special keyword and so it gets ignored, or if there's a bug somewhere.

Any help is appreciated

Xml In:

<entry>
<title>Journal of feline medicine & surgery</title>
<dss:field name="INITIAL_TITLE_SRCH" type="NONE">Journal of feline medicine & surgery</dss:field>
<dss:field name="INITIAL_AUTHOR_SRCH" type="NONE">European Society of Feline Medicine.</dss:field>
</entry>

JSON out:

"entry":{
"title":"Journal of feline medicine & surgery",
"dss:field":[
{
"@xmlns:dss":"http://SirsiDynix.com/discovery/extensions/",
"@name":"INITIAL_TITLE_SRCH",
"#text":"Journal of feline medicine & surgery"
},
{
"@xmlns:dss":"http://SirsiDynix.com/discovery/extensions/",
"@name":"INITIAL_AUTHOR_SRCH",
"#text":"European Society of Feline Medicine."
},
]
},

Discussion


  • Anonymous
    2012-03-24

    Should have read the documentation.

    There is a method setTypeHintsEnabled for XMLSerializer that lets you enable/disable using the 'type' attribute for JSON hints.

    Just call serializer.setTypeHintsEnabled(false) on your XMLSerializer and you'll be golden.

     

  • Anonymous
    2012-03-24

    • status: open --> open-invalid