jsonix icon indicating copy to clipboard operation
jsonix copied to clipboard

Exclude TYPE_NAME property from objects

Open somelinguist opened this issue 8 years ago • 3 comments
trafficstars

Is it possible to exclude the TYPE_NAME property from JS objects after unmarshalling?

somelinguist avatar Apr 13 '17 01:04 somelinguist

Not at the moment. TYPE_NAME is needed for marshalling in some cases.

highsource avatar Apr 13 '17 07:04 highsource

Thanks. That's what I thought.

What kind of cases need it in addition to the PO for for marshalling?

I'm mostly using Jsonix for importing to a similar JSON format as the XML, but would like there possibility of exporting to XML again. I'm wondering if I could remove it programmatically so as to keep the JSON clean and compact, but still be able to export.

somelinguist avatar Apr 14 '17 02:04 somelinguist

You'll need TYPE_NAME for elements property with complex type. This property allows you to map different XML elements onto one property in JavaScript. The specific element name depends on the type of the value, like <s>1</s><i>2</i> may be represented as ['1', 2]. To marshal this correctly, Jsonix will need to distinguish types of values. This is trivial for primitive types. To distinguish types of objects, Jsonix uses the TYPE_NAME property.

If you don't have elements property in you mapping, you can safely drop TYPE_NAME.

highsource avatar Apr 16 '17 17:04 highsource