Git Product home page Git Product logo

Comments (15)

jbourquin avatar jbourquin commented on June 7, 2024 1

Yes, thank you. Looks like it is working as expected.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin Thanks for reporting this. I will look into fixing it. This seems to be a bug in dicttoxml package, but I will fix it.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin I just released the fix for it in the pypi. https://pypi.org/project/json2xml/3.17.0/

Thank you so much for reporting the bug in such detailed manner. 🍺

from json2xml.

jbourquin avatar jbourquin commented on June 7, 2024

No problem, I'm also running into a problem with arrays that contain numbers (like booleans).

So if I convert a JSON object that looks like this:

{
      "boolean_list": [true, false],
      "number_array": [1, 2, 3],
      "string_array": ["a", "b", "c"]
}

It returns the following XML:

<all>
        <item type="bool">True</item>
        <item type="bool">False</item>
        <item type="int">1</item>
        <item type="int">2</item>
        <item type="int">3</item>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

Notice the parent elements are missing for the boolean and number arrays.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

Yeah, I can reproduce it too. Would you like to send a PR to fix this?

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin please let me know if you will sending a fix for it, else I will find sometime this week and fix it.

from json2xml.

jbourquin avatar jbourquin commented on June 7, 2024

I'll take a look, but I probably won't be able to get to it before you do.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

No problem, I'm also running into a problem with arrays that contain numbers (like booleans).

So if I convert a JSON object that looks like this:

{
      "boolean_list": [true, false],
      "number_array": [1, 2, 3],
      "string_array": ["a", "b", "c"]
}

It returns the following XML:

<all>
        <item type="bool">True</item>
        <item type="bool">False</item>
        <item type="int">1</item>
        <item type="int">2</item>
        <item type="int">3</item>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

Notice the parent elements are missing for the boolean and number arrays.

@jbourquin Just fixed and released the fix here: View at:
https://pypi.org/project/json2xml/3.17.1/

Please test and let me know if it works for you and if you are satisfied if the issue is fixd and there is no edge case remaining, please close this issue.

from json2xml.

jbourquin avatar jbourquin commented on June 7, 2024

@vinitkumar Thank you, yes this fixes my problem. I was actually working on a pull request just before your commit. Here is a unit test for these two issues if you would like to integrate it into your repository:
https://github.com/jbourquin/json2xml/blob/master/tests/test_dicttoxml.py

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin Please send me a PR with the tests and I would be more than happy to merge them if I like what I see. Thanks for your hard work.

from json2xml.

jbourquin avatar jbourquin commented on June 7, 2024

@vinitkumar I just tried installing v3.17.1 from PYPI and it seems like the old version of the dicttoxml module is included in the PYPI download instead of the new one with the array fix.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin Are you sure? I just checked the code and it seems like my patch for it is there.

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

@jbourquin Are you sure? I just checked the code and it seems like my patch for it is there.

Ah, I think I understand. What are you are looking for is not implemented in the latest master and has not been released yet. My last fix, made the bool lower case like true and false instead of True or False.

from json2xml.

jbourquin avatar jbourquin commented on June 7, 2024

Yeah, I'm looking for the array fix you released yesterday

from json2xml.

vinitkumar avatar vinitkumar commented on June 7, 2024

A new version of json2xml is released https://pypi.org/project/json2xml/3.18.0/

Please check if that fixes your issue.

from json2xml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.