Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    JSON/XML Conversion in C++ ?

    C++ Gurus
    4
    5
    7523
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • IamSumit
      IamSumit last edited by

      i want to convert JSON to an XML
      How can i achieve it.
      I am using Qt 4.8 and Windows 7

      Be Cute

      fcarney 1 Reply Last reply Reply Quote 0
      • A
        andreyc last edited by

        If your JSON to XML is pretty trivial then you can convert it manually by reading from JSON and writing to XML.
        If the conversion is not trivial then I would suggest to use XSLT to transform and call XSLT processor from C++.
        Some links "xml2json":https://github.com/Cheedoong/xml2json
        If you are going to use Windows only then take a look on MSDN they should have some info about "JSON to XML":http://msdn.microsoft.com/en-us/library/vstudio/bb924435.aspx

        1 Reply Last reply Reply Quote 0
        • D
          Durgesh last edited by

          @andreyc said in JSON/XML Conversion in C++ ?:

          If your JSON to XML is pretty trivial

          @IamSumit Could you have done JSON to XML conversion?

          1 Reply Last reply Reply Quote 0
          • fcarney
            fcarney last edited by

            @andreyc said in JSON/XML Conversion in C++ ?:

            I would suggest to use XSLT to transform

            XSLT requires the source document to be XML. It can do XML to JSON, but not JSON to XML.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply Reply Quote 0
            • fcarney
              fcarney @IamSumit last edited by

              @IamSumit said in JSON/XML Conversion in C++ ?:

              i want to convert JSON to an XML

              I think Qt probably has enough in it to do this. Read up on how to read and parse through a JSON document using the Qt library. Do a recursive printout of the structure to text. Then once you are confident you are reading the entire document then use the Qt library to create your XML document. Also print this out to make sure it matches what you want. You will have to determine a convention of how to translate and this might just be a simple lookup table or a set of rules.

              C++ is a perfectly valid school of magic.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post