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

StackOverflow https://stackoverflow.com/questions/10333527

  •  03-06-2021
  •  | 
  •  

Pergunta

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.

Foi útil?

Solução 2

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

Outras dicas

The json that is at your this piece of json link starts and ends with a double-quote character. Is that actually part of the contents of the json? If it is, I believe that is your problem. Otherwise, it looks like valid json to me.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top