Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding JSON structure - attributes and values
    primarykey
    data
    text
    <p>Something is bothering me. I've used JSON in a few of my apps/websites, we all love it! However something entered my head today which I've never thought about.. take a look at the following example (this is taken from <a href="http://json.org/example.html" rel="nofollow noreferrer">http://json.org/example.html</a> ):</p> <pre><code>{"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } }} </code></pre> <p>now if this was expressed as XML: we would have the following:</p> <pre><code>&lt;widget&gt; &lt;debug&gt;on&lt;/debug&gt; &lt;window title="Sample Konfabulator Widget"&gt; &lt;name&gt;main_window&lt;/name&gt; &lt;width&gt;500&lt;/width&gt; &lt;height&gt;500&lt;/height&gt; &lt;/window&gt; &lt;image src="Images/Sun.png" name="sun1"&gt; &lt;hOffset&gt;250&lt;/hOffset&gt; &lt;vOffset&gt;250&lt;/vOffset&gt; &lt;alignment&gt;center&lt;/alignment&gt; &lt;/image&gt; &lt;text data="Click Here" size="36" style="bold"&gt; &lt;name&gt;text1&lt;/name&gt; &lt;hOffset&gt;250&lt;/hOffset&gt; &lt;vOffset&gt;100&lt;/vOffset&gt; &lt;alignment&gt;center&lt;/alignment&gt; &lt;onMouseUp&gt; sun1.opacity = (sun1.opacity / 100) * 90; &lt;/onMouseUp&gt; &lt;/text&gt; &lt;/widget&gt; </code></pre> <p>When looking at JSON to XML transformation I'm wondering if is there is any way that you can distinguish if a pair ("key":"value") are a attribute of a tag. For example, in our JSON above</p> <pre><code>"window": { "title": "Sample Konfabulator Widget", "name": "main_window", </code></pre> <p>title is represented as an attribute of the window tag whilst name is a tag in it's own right, however this isn't expressed anywhere (that I can see).</p> <pre><code>&lt;window title="Sample Konfabulator Widget"&gt; &lt;name&gt;main_window&lt;/name&gt; </code></pre> <p>Why isn't this displayed as:</p> <pre><code>&lt;window&gt; &lt;title&gt;Sample Konfabulator Widget&lt;/title&gt; &lt;name&gt;main_window&lt;/name&gt; </code></pre> <p>Is their a way I can specify if a pair are an attribute of the parent tag or a child tag in their own right? Sorry if my wording is bad or if I'm not explaining myself well.</p>
    singulars
    1. This table or related slice is empty.
    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