jsonsjcl

Why does SJCL report "this is not JSON" when trying to decode this JSON snippet?


I'm using SJCL, and it works fine with small ASCII strings.

But when I try to decode this piece of JSON (the result of the encryption of an HTML page) I get a "this is not JSON!" error.

The JSON has been produced by SJCL, and while I did encode it and decode it using LZW and base64 I don't get this error for small strings with the same workflow.

I tracked the error message origin to the decode function. I assume the regexes are failing but I don't understand why as this seems to be a perfectly formed JSON string to me.

However, I can be wrong as if I do a JavaScript eval on it it fails on a syntax error. But if I dump it in a file Python parse it fine.


Solution

  • Ok I made a double passed base64 encoding. One before encryption, and one after. It seems that removing the first pass make it work.