json2xml icon indicating copy to clipboard operation
json2xml copied to clipboard

Preserve certain text from being escaped

Open ernieIzde8ski opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

In a project, I need to preserve ampersands inside text so that I can have the following nodes:

	<class> &InventoryMenu; </class>
	<alpha>	0 </alpha> 
	<locus> &true; </locus>

However, inserting an ampersand as normal results in it being escaped to &amp. I couldn't tell if there were some mechanism in the library for preventing that behavior already, but it would be useful to have one.

Describe the solution you'd like

A backwards-slash-based solution seems the most straightforward, like:

{
    "class": "\\&InventoryMenu;",
    "alpha": 0,
    "locus": "\\&true;"
}

Describe alternatives you've considered

Some macro-based solutions came to mind, but none that seemed reasonable.

ernieIzde8ski avatar Sep 22 '23 11:09 ernieIzde8ski

Thanks for reporting this. I will need to think about a way to implement it in a backward compatible way. Let me get back to you on this.

vinitkumar avatar Sep 22 '23 14:09 vinitkumar

@ernieIzde8ski I just looked into this. It looks like escaping is the correct thing to do in this case and there is no good way to implement this without breaking backward compatibility.

vinitkumar avatar Sep 23 '23 20:09 vinitkumar