What changes when XML becomes JSON
The two formats do not describe the same shape of data, so a conversion always makes choices. XML distinguishes attributes from child elements and allows the same tag to repeat; JSON has neither concept. The compact convention used here maps attributes to _attributes, text to _text, and a repeated tag to an array — which is why the output for one <book> and for two of them is not the same shape.
Order is the other thing to watch. XML guarantees document order among sibling elements; JSON object keys do not carry that guarantee, so mixed content — text interleaved with elements — is the case where a round trip is least likely to give you back what you started with.
Working the other way
To go from JSON back to XML, use JSON to XML. To tidy XML before converting it, the XML beautifier re-indents it without changing the content, and JSON formatter does the same for the output.