<br>(This was on the sourceforge feature requests, I&#39;m taking the liberty to move it directly to pd-dev)<div><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
Initial Comment:<br>
Hi all !<br>
<br>
With several people from *libpd* and other *pd* offsprings, we have been thinking that it would be great to have an alternative format for pd files (see: <a href="http://noisepages.com/groups/pd-everywhere/forum/topic/javascript-json-apis/" target="_blank">http://noisepages.com/groups/pd-everywhere/forum/topic/javascript-json-apis/</a>).<br>

Problem is that the current format is very tedious to parse ; it is very messy (as seen in the complexity of the documentation) ; and last but not least, it doesn&#39;t separate the actual graph data from the GUI data (X, Y, canvases, ...). Overall, this is not good for interoperability between different pd/non-pd systems.<br>

<br>
We were thinking that a simple JSON file would save a lot of trouble :<br>
- it has a nested structure, which allows for much clearer, even human-readable format. ex :<br>
[<br>
    {&quot;class&quot;: &quot;obj&quot;, &quot;id&quot;: 0, &quot;type&quot;: &quot;osc~&quot;, &quot;args&quot;: [440]},<br>
    {&quot;class&quot;: &quot;obj&quot;, &quot;id&quot;: 1, &quot;type&quot;: &quot;dac~&quot;},<br>
    {&quot;class&quot;: &quot;connect&quot;, &quot;from&quot;: [0, 0], &quot;to&quot;: [1, 0]},<br>
    {&quot;class&quot;: &quot;connect&quot;, &quot;from&quot;: [0, 0], &quot;to&quot;: [1, 1]}<br>
]<br>
<br>
- it allows putting custom attributes (for a GUI for example) :<br>
[<br>
    {&quot;class&quot;: &quot;obj&quot;, &quot;id&quot;: 0, &quot;type&quot;: &quot;osc~&quot;, &quot;args&quot;: [440],<br>
        &quot;myGui&quot;: {&quot;x&quot;: 123, &quot;y&quot;: 78}<br>
    }<br>
]<br>
<br></div></div></blockquote><div><br></div><div>Strict json has a dictionary as it&#39;s outermost object.  Most parsers will accept an array as you have done, but not all (Obj-C&#39;s TouchJSON as an example).  An alternative way to organize the patch and adhere to strict json would be to have id&#39;s on the outside, such as:</div>
<div><br></div><div><div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;canvas&quot; :</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;id&quot; : 1,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;name&quot; : &quot;example&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;x&quot; : 95,</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;y&quot; : 190,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;width&quot; : 809,</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;height&quot; : 538</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;elements&quot; :</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;obj&quot; : {&quot;id&quot; : 0, &quot;type&quot;: &quot;osc~&quot;, &quot;args&quot;: [440]},</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;obj&quot; : {&quot;id&quot; : 1, &quot;type&quot;: &quot;dac~&quot;},</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;connect&quot; : {&quot;from&quot;: [0, 0], &quot;to&quot;: [1, 0]},</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;connect&quot; : {&quot;from&quot;: [0, 0], &quot;to&quot;: [1, 1]}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div>
<span class="Apple-tab-span" style="white-space:pre">                </span>&quot;canvas&quot; : { ... }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;array&quot; : { ... }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div>}</div></div></div><div><br></div><div>About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.  To make the dimensions optional means interoperability with pd will be optional, probably not so good.  If you need extra info, I think that&#39;s ok, but at a minimum the information in existing pd patches should be represented.</div>
<div><br></div><div>You could also pull the GUI locations into a separate object:</div><div><br></div><div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;canvas&quot; :</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;id&quot; : 0,</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;name&quot; : &quot;example&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;elements&quot; :</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;obj&quot; : {&quot;id&quot; : 0, &quot;type&quot;: &quot;osc~&quot;, &quot;args&quot;: [440]},</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;obj&quot; : {&quot;id&quot; : 1, &quot;type&quot;: &quot;dac~&quot;},</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;connect&quot; : {&quot;from&quot;: [0, 0], &quot;to&quot;: [1, 0]},</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;connect&quot; : {&quot;from&quot;: [0, 0], &quot;to&quot;: [1, 1]}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div>
<span class="Apple-tab-span" style="white-space:pre">                </span>&quot;layout&quot; :</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;0&quot; : { &quot;pos&quot;: [123, 78] },</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;1&quot; : { &quot;pos&quot;: [123, 100] }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;layout&quot; :</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>&quot;0&quot; : { &quot;pos&quot;: [95, 190], &quot;size&quot; : [809, 538] }</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div><br></div><div>Don&#39;t know if it&#39;s better or worse, just throwing it out there.  One side effect is that the id&#39;s here are both in string and int format.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><br>
----------------------------------------------------------------------<br>
<br>
</div></div><div class="im">Comment By: Andras Muranyi (muranyia)<br>
</div>Date: 2012-06-01 14:00<br>
<br>
Message:<br>
@reakin: when mentioning two files for one patch i was referring to the<br>
(nice and convenient) idea of separating logic from presentation by<br>
breaking out GUI info into a CSS-like file - which means having two files<br>
per patch (not so convenient and nice). <div class="HOEnZb"><div class="h5">
<br></div></div></blockquote><div><br></div><div>Ah, understood.  I also think this would be a bit overcomplicated.  If it&#39;s separated, I think the GUI info could just be under a different object in the json of one file.</div>
<div> </div><div>Cheers,</div><div>Rich</div></div></div>