Json paring error in web client

I posted an issue on github which was closed since I forgot “” around test. I’ve updated an still get an error. I did not want to open a new issue for it since the last was closed so I’ll try here.

github: https://github.com/dgraph-io/dgraph/issues/4467

Running this mutation causes an error:

  "set": [
   {"test": "testing"},

Error: t: while lexing { “set”: [ {“test”: “testing”}, ] } at line 2 column 2: Unrecognized character inside mutation: U+0022 ‘"’

Please, remove the comma. With it isn’t a valid JSON https://jsonlint.com/

I’ve removed it, still same error

That’s odd, if I just remove the comma it works in my side. Check the quote marks. Sometimes when you copy it from other sites it comes with a different character. Paste and test the JSON in any lint tool you find in the internet and you gonna have a valid JSON.

You can search by “Json lint” and you gonna find varied tools for it.

PS. Also note that the Unicode in the error is related to quote marks Unicode Character 'QUOTATION MARK' (U+0022)
So that means this quote marks are invalid for the parse. You should use other or there is something between the quotation marks. And in that case is the comma.

There is something wired going on here. Tried it in https://jsonlint.com/ and it says it’s valid. But it does not work in Ratel

I’m using a Norwegian keyboard layout, might that be it?

Sorry, but I have no idea what it can be. Try to use the HTTP API via Curl. If it’s related to Ratel only, it shouldn’t happen via Curl.


I can reproduce this but only through trickery.

If you type the JSON object out, or copy/paste it from this Markdown-enabled forum, the query works fine. However, if you type it out and accidentally use a non-ASCII whitespace character immediately before the { on the third line you’ll see the error message. An easy way to do this on a Mac is to highlight the space (or tab) before { with Option-Space (which inserts a “thin space”). There’s probably ways to do this on Windows and Linux.

Unfortunately I don’t know how to make a copy-pasteable example that Markdown won’t neuter.

In this case, the bug appears to be in the lexer’s error reporting or Go’s json parser. The error message suggests that the unrecognized character is U+0022 on line 2, which is indeed ", but in actuality the unrecognized character should be U+2009 on line 3.

I tested this on a hunch based on the spacing in the original JSON, where line 3 had 3 spaces instead of 4.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.