Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid characters for JSON and XML differs: What could be done #34

Closed
kra3 opened this issue Dec 16, 2015 · 2 comments
Closed

Valid characters for JSON and XML differs: What could be done #34

kra3 opened this issue Dec 16, 2015 · 2 comments
Assignees
Labels
enhancement released Issue has been released
Milestone

Comments

@kra3
Copy link

kra3 commented Dec 16, 2015

Syntax rules for JSON and XMLs are not always compatible.
For example, A JSON data such as {"16x16": "image_url"} can't be converted to <o><16x16>image_url</16x16></o> as XML tag name can't be started with a number.

Is there a workaround for this already in place in the library, if yes what is it? if not what's the expected solution to address such scenarios?

@aalmiray aalmiray self-assigned this Sep 30, 2022
@aalmiray aalmiray added this to the 3.0.3 milestone Sep 30, 2022
@aalmiray
Copy link
Collaborator

The following snippet shows the new mappedPropertyNames option available in XMLSerializer:

        JSONObject jsonObject = JSONObject.fromObject("{\"16x16\": \"image_url\"}");
        String expected = "<o><image_16x16 type=\"string\">image_url</image_16x16></o>";
        xmlSerializer.addMappedPropertyName("16x16", "image_16x16");
        String xml = xmlSerializer.write(jsonObject);
        assertXMLEqual(expected, xml);

@github-actions github-actions bot added the released Issue has been released label Sep 27, 2024
Copy link
Contributor

🎉 This issue has been resolved in v3.1.0 (Release Notes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement released Issue has been released
Projects
None yet
Development

No branches or pull requests

2 participants