Returns a JSON object from a Map element.

1 json.fromXML

<json.fromXML>
    <xml /> !
</json.fromXML>
Example
Copy
<xsql-script name='test_json_fromXML'>
    <body>
      <println>
        <json.fromXML>
          <dom.parse>
            <![CDATA[
              <h1 name='a' value='20'>
                <h2 name='b' link='10' />
              </h1>
            ] ]>
          </dom.parse>
        </json.fromXML>
      </println> 
    </body>
</xsql-script>
Copy
{
"h1" : {


   "h2" : {
       "link" : "10",
       "name" : "b"
   },
   "name" : "a",
   "value" : "20"

}

}
Example
Copy
<xsql-script name='test_json'>
   <body>

       <set name='m_factura'>
           <dom.parse>
               <file name='FAC00001.xml' type='absolute' />
           </dom.parse>
       </set>
       

<!--

The XML document has the following structure (stored in the file 'FAC00001.xml').

<Invoice>


   <CompanyCode>E01</CompanyCode>
   <InvoiceDate>2007-12-31</InvoiceDate>
   <InvoiceNumber>0712GL-00001</InvoiceNumber>
   <DelegationCode>080101</DelegationCode>
   <ThirdCode>E12345678</ThirdCode>
   <InvoiceType></InvoiceType>
   <OriginInvoice></OriginInvoice>
   <Taxes>
       <VatType>SEX</VatType>
       <TaxBase>5500</TaxBase>
       <Fee>0</Fee>
   </Taxes>
   <Taxes>
       <VatType>SRE</VatType>
       <TaxBase>1500</TaxBase>
       <Fee>100</Fee>
   </Taxes>
   <Currency>EUR</Currency>
   <Classification>23</Classification>
   <TotalAmount>7100</TotalAmount>
   <NetAmount>7000</NetAmount>
   <Discount>0</Discount>
   <InvoiceLine>
       <ItemCode>AR00001</ItemCode>
       <Description>PAPEL GL</Description>
       <Quantity>300</Quantity>
       <Price>5</Price>
       <NetAmount>1500</NetAmount>
       <Project>08</Project>
       <Section>01</Section>
       <CenterCost>0</CenterCost>
       <ThirdSending>080101</ThirdSending>
       <SendingAdress>0</SendingAdress>
   </InvoiceLine>
   <InvoiceLine>
       <ItemCode>AR00002</ItemCode>
       <Description>PAPEL BLANCOL</Description>
       <Quantity>100</Quantity>
       <Price>3</Price>
       <NetAmount>300</NetAmount>
       <Project>08</Project>
       <Section>01</Section>
       <CenterCost>0</CenterCost>
       <ThirdSending>080101</ThirdSending>
       <Sending_Adress>0</SendingAdress>
   </InvoiceLine>

</Invoice>  

-->     


       <!-- Given an XML dom element, transform into a JSON memory object -->
       <set name='m_json'>
           <json.fromXML>
               <m_invoice />
           </json.fromXML>
       </set>
   
       <println>
           <m_json />
       </println>
   

<!--

The json structure is shown as:

{


   "Invoice":
   {
       "InvoiceType":null,
       "OriginInvoice":null,
       "CompanyCode":"E01",
       "NetAmount":"7000",
       "Currency":"EUR",
       "InvoiceNumber":"0712GL-00001",
       "Classification":"23",
       "InvoiceLine":[
           {
               "Project":"08",
               "Quantity":"300",
               "ThirdSending":"080101",
               "ItemCode":"AR00001",
               "Price":"5",
               "CenterCost":"0",
               "Section":"01",
               "NetAmount":"1500",
               "SendingAdress":"0",
               "Description":"PAPEL GL"
           },
           {
               "Project":"08",
               "Quantity":"100",
               "ThirdSending":"080101",
               "ItemCode":"AR00002",
               "Price":"3",
               "CenterCode":"0",
               "Section":"01",
               "NetAmount":"300",
               "SendingAdress":"0",
               "Description":"WHITE PAPER"
           }
       ],
       "ThirdCode":"E12345678",
       "TaxBase":[
           {
               "VatType":"SEX",
               "Fee":"0",
               "TaxBase":"5500"
           },
           {
               "VatType":"SRE",
               "Fee":"100",
               "TaxBase":"1500"
           }
       ],
       "Discount":"0",
       "DelegationCode":"080101",
       "TotalAmount":"7100",
       "InvoiceDate":"2007-12-31"
   }

}

-->     


       <println>CompanyCode = <json.get name='Invoice.CompanyCode'><m_json /></json.get></println>
       <iterator name='m_taxbase'>
           <in>
               <json.get name='Invoice.Taxes'><m_json /></json.get>
           </in>
           <do>
               <println>Taxes -------------- </println>
               <println>VatType = <json.get name='TipoIva'><m_taxes /></json.get></println>
               <println>TaxBase = <json.get name='TaxBase'><m_taxes /></json.get></println>
               <println>Fee = <json.get name='Fee'><m_taxes /></json.get></println>
           </do>
       </iterator>

   </body>

</xsql-script>
Copy
CompanyCode = E01
TAXES --------------
VatType = SEX
TaxBase = 5500
Fee = 0
TAXES --------------
VatType = SRE
TaxBase = 1500


Fee = 100