xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

Converts multiple comments when using json2xml() function

Open byeokim opened this issue 5 years ago • 0 comments

When converting JavaScript Object/JSON to XML, sometimes it needs to have more than one comment.

For example, the following JSON object has two comments:

{
  "comment1": "Comment for title",
  "title": "Happy",
  "comment2": "Comment for todo",
  "todo": "Work"
}

Corresponding XML object should look like this:

<!--Comment for title-->
<title>Happy</title>
<!--Comment for todo-->
<todo>Work</todo>

In this commit, json2xml() function makes it possible by regarding any name of the property key which starts with options.commentKey as key for comment property. For example, if options.commentKey is $comment, then $comment1, $comment_title as well as $comment are regarded as keys for comment property.

byeokim avatar Nov 06 '18 04:11 byeokim