sutee
sutee

Reputation: 12828

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.

Upvotes: 5

Views: 3488

Answers (1)

juandopazo
juandopazo

Reputation: 6329

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]}"}}.

Upvotes: 2

Related Questions