0

I tried to connecting JSON into my db to access the users list, but I got this error:

Uncaught Unable to parse the JSON returned by the server: You're trying to decode an invalid JSON String: [{gid:"7503",cn:"Marketing",}]
Notice: Undefined variable: ldapcon in C:\xampp\htdocs\site\resources\admin\getGroups.php on line 38

I guess, I forgot to put comma inside it, can you please help me?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
da_root
  • 364
  • 2
  • 11
  • 1
    Validate the json with [jsonlint](http://jsonlint.com/) – HPierce Sep 11 '15 at 21:25
  • You did not forget to put a comma, there's one comma too much. – Jan Doggen Sep 11 '15 at 21:33
  • 1
    How did you get that broken JSON? You should use `json_encode()` in the PHP script, not try to create JSON by hand. – Barmar Sep 11 '15 at 21:34
  • you right Barmar I am not using the json_encode, maybe I should change my code, @samlev, after I remove the comma, I got error protocol, I will add the protocol code (V3). Hope I am lucky – da_root Sep 11 '15 at 21:46

1 Answers1

4

JSON requires the keys to be in double-quoted strings, and there can't be a trailing comma:

{"gid":"7503","cn":"Marketing"}
samlev
  • 5,852
  • 1
  • 26
  • 38