Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML::XML2JSON "0" Element

Tags:

json

xml

perl

I'm using XML::XML2JSON in Perl to convert JSON data to XML, I am passing through the following data (snippet):

{"question":{"isrequired":{"$t":"0"}}}

and when I use the XML:XML2JSON->json2xml function to convert the JSON data into XML, I get the following (snippet):

<isrequired/>

I need to retain the "0" element in the "isrequired" tag, because at times, I will have empty JSON elements, and need the empty XML tag. I think the documentation is a bit vague (either that, or I don't understand it), but is this possible to do with this module?

I would appreciate the help. Thanks.

like image 729
Kevin C Avatar asked Feb 03 '26 09:02

Kevin C


1 Answers

Try a "zero but true" value instead of "0":

" 0 "
" 0"
"0E0"
like image 135
mob Avatar answered Feb 04 '26 23:02

mob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!