Is it possible to use references in JSON?
<p>I have this JSON:</p>

<pre><code>{
    "app_name": "my_app",
    "version": {
        "1.0": {
            "path": "/my_app/1.0"
        },
        "2.0": {
            "path": "/my_app/2.0"   
        }
    }
}
</code></pre>

<p>Is it somehow possible to reference the keywords <code>app_name</code> and the key of <code>version</code> so that I don't have to repeat "my_app" and the version numbering?</p>

<p>I was thinking something along the lines of... (code totally made up):</p>

<pre><code>{
    "@app_name": "my_app",
    "version": {
        "1.0": {
            "path": "/{{$app_name}}/{{key[-1]]}}"
        },
        "2.0": {
            "path": "/{{$app_name}}/{{key[-1]}}"    
        }
    }
}
</code></pre>

<p>Or is this something that could instead be handled better using YAML?</p>

<p>In the end, I intend to read this data into a Python dictionary.</p>

<p>No, JSON does not have references. (The functionality you request here, with substring expansion, would open itself to memory attacks against the parser; by not supporting this functionality, JSON avoids vulnerability to such attacks).</p>

<p>If you want such functionality, you need to implement it yourself.</p>

python json yaml