Hi Danielo

I don't think that that code is a great approach. There's too much scope
for variable substitution to break the JSON formatting. In particular, JSON
needs string constants to be encoded if they include double quotes, and the
variable substitution mechanism isn't capable of that. It would be much
better to apply variable substitution to each field in turn.

Can you log the complete original JSON string as well as the value that
comes out of substituteVariableReferences?

Best wishes

Jeremy



On Tue, Nov 4, 2014 at 11:54 AM, Danielo Rodríguez <[email protected]>
wrote:

> Hello,
>
> I traced down the code and the problem is on the JSON.parse part.
> After the substituteVariableReferences execution, JSON.parse will receive
> the following string:
>
>  "{"text":"Now↵Try
> ↵LB","bag":"default","revision":"0","type":"text/vnd.tiddlywiki","title"
>
> Which does not seems to be a valid JSON string.
> The code that fails is like this
>
> // Make the clone of the template
>  var make = this.wiki.getTiddlerAsJson(this.maketidTemplate);
>  debugger;
>  var tempTest =this.substituteVariableReferences(make);
>  var makeClone = JSON.parse(tempTest);
>
> The problem is that substituteVariableReferences returns that string with
> those unexpected characters. Maybe the substituteVariableReferences should
> return \n instead?
>
> El martes, 4 de noviembre de 2014 12:38:07 UTC+1, Jeremy Ruston escribió:
>>
>> Hi Danielo
>>
>> There's no problem that I can see with the snippet you posted above. Can
>> you put up a minimal test case?
>>
>> Best wishes
>>
>> Jeremy
>>
>>
>> On Tue, Nov 4, 2014 at 11:27 AM, Danielo Rodríguez <[email protected]>
>> wrote:
>>
>>> The error is much more concise in firefox:
>>>
>>> SyntaxError: JSON.parse: bad control character in string literal at line
>>> 1 column 13 of the JSON data
>>>
>>> Why?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "TiddlyWiki" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/tiddlywiki.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Jeremy Ruston
>> mailto:[email protected]
>>
>


-- 
Jeremy Ruston
mailto:[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to