You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.
toXml method should be able to reverse the JSON with different keys in the text nodes
Current Behavior
When using the toJson method with the reversible and ʻalternateTextNode` option set to true, the response returned by the method is not reversible with the toXml method.
Parse a valid xml with the toJson method, the method must have the reversible and alternateTextNode options.
The returned object must be passed to the toXml method.
Possible Implementation
File lib/json2xml.js ToXml class
functionToXml(options){vardefaultOpts={sanitize: false,ignoreNull: false,alternateTextNode: false,};if(options){for(varoptinoptions){defaultOpts[opt]=options[opt];}}this.options=defaultOpts;this.xml='';this.tagIncomplete=false;if(typeofthis.options.alternateTextNode==="boolean"){thist.textNodeKey=this.options.alternateTextNode ? "_t" : "$t";}elseif(typeofthis.options.alternateTextNode==="string"){this.textNodeKey=this.options.alternateTextNode;}else{// or set by default "$t"thrownewError("Expected string or boolean value for the alternateTextNode option");}}
Expected Behavior
toXml
method should be able to reverse the JSON with different keys in the text nodesCurrent Behavior
When using the
toJson
method with thereversible
and ʻalternateTextNode` option set to true, the response returned by the method is not reversible with the toXml method.Possible Solution
add the
alternateTextNodes
option in theToXml
class and use this option to evaluate if the element is a text nodeSteps to Reproduce
toJson
method, the method must have thereversible
andalternateTextNode
options.toXml
method.Possible Implementation
File
lib/json2xml.js
ToXml classFile
lib/json2xml.js
line 39The text was updated successfully, but these errors were encountered: