Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting inline JSON to parse

Are there any tricks to get this inline json object to parse? $a[3] is a mako variable containing a url.

<li class="foldernode" yuiConfig='{"type":"TextNode","data":"{&#39;myurl&#39;:&#39;${a[3]}&#39;}"}'>

Without the "type" attribute it works:

<li class="foldernode" yuiConfig='{"data":"{&#39;myurl&#39;:&#39;${a[3]}&#39;}"}'>

I already had to do something hacky and use &#39; for single quotes which I then replace with double quotes in javascript. Any general strategies for doing this type of nested quoting would be helpful.

like image 392
sutee Avatar asked Nov 04 '22 09:11

sutee


1 Answers

A trick I usually use it to write the object in generic JavaScript, call JSON.stringify on it and copy the result. The result I got was {"type":"TextNode","data":{"myurl":"${a[3]}"}}.

like image 102
juandopazo Avatar answered Nov 14 '22 23:11

juandopazo