skip to Main Content

I’m not used to working on json files. As shown in the image below, when I copy the content in PublicPem field of json file, it shows red curly lines at three places, and gives me the warning Unexpected end of string. Question: How can we fix this error – and what’s the cause of the error?

enter image description here

2

Answers


  1. Have you checked to make sure there’s no new line characters? Paste the JSON into a text editor and make sure it is plain text with no unprintable characters, like newline. Since your publicPem entry is so neatly formatted and your privatePem entry goes past, I bet this is the problem and hence the unterminated string error.

    You could also try pasting the JSON into an online JSON formatter.

    p.s. Next time asking a question like this, post the text and not an image. Then someone who answers the question could actually check that for you.

    Login or Signup to reply.
  2. You have newlines in the middle of a string:

    JSON.parse(`{"id": "hello
    world");

    It needs to be a single line:

    JSON.parse(`{"id": "hello world"}`);

    Or, (depending on how you implement it), you may be able to do:

    JSON.parse(`{"id": "hello 
    world"}`);
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search