Reputation:
When I am converting the below JSON
to XML
, it seems that __text
property is being stripped off from the XML.
{
"root": {
"number": {
"__text": "1\n-\n222\n-\n500"
}
}
}
Can anyone tell how the __text
property changes and what __text
represents?
Below is a fiddle and library used
http://jsfiddle.net/abdmob/gtLBx/15/
https://code.google.com/p/x2js/
Upvotes: 1
Views: 300
Reputation: 1747
The __text
property changes from the Javascript
syntax of a multi-line string to the XML
syntax of a multi-line string.
This means that \n
is converted to a newline.
1\n-\n222\n-\n500
will then become
1
-
222
-
500
which is the same, in different notation
Without knowing the library you're using, I'd guess that __text
represents the content of the property you're describing.
Looking into the source of the library it seems like _
indicates an attribute and the attribute __text
is a special attribute to indicate the text contained inside an XML element when the element also has attributes.
Here is an updated fiddle that should help you to understand this better: https://jsfiddle.net/gtLBx/924/
Here are the source code snippets, that imply the things I assumed:
_
is an attribute, because of line 31:
config.attributePrefix = config.attributePrefix || "_";
_text
is the name of an internal attribute, because of this line 272:
result.__text = result.__text.join("\n");
Upvotes: 1