Json tool for XML?

I have one json file, but an application in which I use import data only from xml files. So does anyone know a tool that converts json files to xml? I searched for such a tool for several hours and could only find tools that create json files from xml.

Thanks!

+3
source share
2 answers

If you are using the .NET Framework, you can do this in code:

  • Create a JSON reader through JSON content using the JsonReaderWriterFactory class
  • Create a regular XmlWriter and call WriteNode on it so that it reads JSON. It will write out XML corresponding to your JSON.

Cautions:

  • JSON-to-XML Microsoft ( ). XML .
  • , .NET3.5. , .NET 3.5 SP1, , 4.0, Silverlight 3
0

XSLT 2.0:

f:json-document() FXSL 2.x.

JSon , ... XML.

, XPath:

f:json-document($vstrParam)/Students/*[sex = 'Female']

Students sex = 'Female'

:

<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:f="http://fxsl.sf.net/"
 exclude-result-prefixes="f xs"
 >
 <xsl:import href="../f/func-json-document.xsl"/>

 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:variable name="vstrParam" as="xs:string">
{

  "teacher":{
    "name":
      "Mr Borat",
    "age":
      "35",
    "Nationality":
      "Kazakhstan"
             },


  "Class":{
    "Semester":
      "Summer",
    "Room":
      null,
    "Subject":
      "Politics",
    "Notes":
      "We're happy, you happy?"
           },

  "Students":
    {
      "Smith":
        {"First Name":"Mary","sex":"Female"},
      "Brown":
        {"First Name":"John","sex":"Male"},
      "Jackson":
        {"First Name":"Jackie","sex":"Female"}
    }
    ,


  "Grades":

    {
      "Test":
      [
        {"grade":"A","points":68,"grade":"B","points":25,"grade":"C","points":15},

        {"grade":"C","points":2, "grade":"B","points":29, "grade":"A","points":55},

        {"grade":"C","points":2, "grade":"A","points":72, "grade":"A","points":65}
       ]
    }


}
 </xsl:variable>

 <xsl:template match="/">
    <xsl:sequence select=
     "f:json-document($vstrParam)/Students/*[sex = 'Female']"/>

 </xsl:template>
</xsl:stylesheet>

XML- (), :

<Smith>
   <First_Name>Mary</First_Name>
   <sex>Female</sex>
</Smith>
<Jackson>
   <First_Name>Jackie</First_Name>
   <sex>Female</sex>
</Jackson>
0

Source: https://habr.com/ru/post/1719469/


All Articles