Note that there are some explanatory texts on larger screens.

plurals
  1. POxml data lost in JSON conversion
    primarykey
    data
    text
    <p>I am getting the following result from converting xml to JSON, using more than one conversion library. As you can see, the property name attributes are lost, as are the Item name attributes. Why?</p> <p>Does anyone have recommendations on how I might change my XML to make it more conversion friendly?</p> <pre><code>&lt;Asset name="xyz"&gt; &lt;Property name="p1"&gt;Value 1&lt;/Property&gt; &lt;Property name="p2"&gt;Value 2&lt;/Property&gt; &lt;TimeSeries name="TimeSeries Name 1"&gt; &lt;Item name="30 Apr 2009"&gt;97.47219&lt;/Item&gt; &lt;Item name="01 May 2009"&gt;97.16496&lt;/Item&gt; &lt;Item name="05 May 2009"&gt;97.34606&lt;/Item&gt; &lt;/TimeSeries&gt; &lt;/Asset&gt; </code></pre> <p>Retuns </p> <pre><code>{"Asset":{"@attributes":{"name":"xyz"}, "Property":["Value 1","Value 2"], "TimeSeries":{"@attributes":{"name":"TimeSeries Name 1"}, "Item":["97.47219","97.16496","97.34606"]}}} </code></pre> <p>I have tried the following, but both the XML and JSON are a lot more verbose:</p> <pre><code>&lt;Asset name="xyz"&gt; &lt;Property&gt;&lt;name&gt;p1&lt;/name&gt;&lt;value&gt;Value 1&lt;/value&gt;&lt;/Property&gt; &lt;Property&gt;&lt;name&gt;p2&lt;/name&gt;&lt;value&gt;Value 2&lt;/value&gt;&lt;/Property&gt; &lt;TimeSeries name="TimeSeries Name 1"&gt; &lt;Item&gt;&lt;date&gt;30 Apr 2009&lt;/date&gt;&lt;value&gt;97.47219&lt;/value&gt;&lt;/Item&gt; &lt;Item&gt;&lt;date&gt;01 May 2009&lt;/date&gt;&lt;value&gt;97.16496&lt;/value&gt;&lt;/Item&gt; &lt;Item&gt;&lt;date&gt;05 May 2009&lt;/date&gt;&lt;value&gt;97.34606&lt;/value&gt;&lt;/Item&gt; &lt;/TimeSeries&gt; &lt;/Asset&gt; </code></pre> <p>resulting in...</p> <pre><code>{"Asset":{"@attributes":{"name":"xyz"}, "Property":[{"name":"p1","value":"Value 1"},{"name":"p2","value":"Value 2"}], "TimeSeries":{"@attributes":{"name":"TimeSeries Name 1"}, "Item":[{"date":"30 Apr 2009","value":"97.47219"}, {"date":"01 May 2009","value":"97.16496"},{"date":"05 May 2009","value":"97.34606"}]}}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload