{"action":"created","issue":{"url":"https://api.github.com/repos/google/gson/issues/494","repository_url":"https://api.github.com/repos/google/gson","labels_url":"https://api.github.com/repos/google/gson/issues/494/labels{/name}","comments_url":"https://api.github.com/repos/google/gson/issues/494/comments","events_url":"https://api.github.com/repos/google/gson/issues/494/events","html_url":"https://github.com/google/gson/issues/494","id":63059655,"number":494,"title":"Fix interpretation of trailing comma when setLenient() is true.","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2015-03-19T18:33:18Z","updated_at":"2017-02-04T14:32:34Z","closed_at":null,"body":"```\nThe following code exhibits the issue:\n\n    StringReader reader = new StringReader(\"{foo: ['bar', 'baz',]}\");\n    JsonReader jsonReader = new JsonReader(reader);\n    jsonReader.setLenient(true);\n    JsonParser parser = new JsonParser();\n    JsonElement root = parser.parse(jsonReader);\n    assertEquals(\n        \"Trailing comma should be ignored like in ECMAScript 5.\",\n        2,\n        root.getAsJsonObject().get(\"foo\").getAsJsonArray().size());\n\nCurrently, GSON returns an array that corresponds to:\n\n    [\"bar\", \"baz\", null]\n\nInstead of:\n\n    [\"bar\", \"baz\"]\n\nThis is atrocious. The current behavior is consistent with bad browser behavior \nfrom the last decade. The expected behavior is consistent with ECMAScript 5, as \nwell as any programmer who has ever wanted trailing commas to be ignored so \nthat it is easier to write lists of things. Here is more information on the \nbadness of the current JSON spec:\n\n    http://bolinfest.com/essays/json.html\n\nPlease, please fix this. Anyone who uses JSON for a config language wants to be \nable to write data like this:\n\n   [\n     \"foo\",\n     \"bar\",\n   ]\n\nsuch that it is possible to add something to the list without having to clean \nup the comma from the previous line. The current behavior is incredibly \ncounterintuitive.\n\nAlso, while we're on the subject, the trailing comma should also be supported \nfor map entries:\n\n  {\n    \"foo\": 42,\n    \"bar\": 24,\n  }\n\nAgain, this makes it considerably easier to maintain JSON data files.\n\n```\n\nOriginal issue reported on code.google.com by `bolinf...@gmail.com` on 6 Jan 2013 at 11:58\n"},"comment":{"url":"https://api.github.com/repos/google/gson/issues/comments/277449539","html_url":"https://github.com/google/gson/issues/494#issuecomment-277449539","issue_url":"https://api.github.com/repos/google/gson/issues/494","id":277449539,"user":{"login":"BoD","id":372852,"avatar_url":"https://avatars.githubusercontent.com/u/372852?v=3","gravatar_id":"","url":"https://api.github.com/users/BoD","html_url":"https://github.com/BoD","followers_url":"https://api.github.com/users/BoD/followers","following_url":"https://api.github.com/users/BoD/following{/other_user}","gists_url":"https://api.github.com/users/BoD/gists{/gist_id}","starred_url":"https://api.github.com/users/BoD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BoD/subscriptions","organizations_url":"https://api.github.com/users/BoD/orgs","repos_url":"https://api.github.com/users/BoD/repos","events_url":"https://api.github.com/users/BoD/events{/privacy}","received_events_url":"https://api.github.com/users/BoD/received_events","type":"User","site_admin":false},"created_at":"2017-02-04T14:32:33Z","updated_at":"2017-02-04T14:32:33Z","body":"Wow I've just seen bug #401 and from what I understand, `jsonReader.setLenient(true);` is simply ignored, and therefore (please correct me if I'm wrong),\r\n1/ trailing commas are always valid\r\n2/ they are interpreted as null items\r\n3/ there's no way to change this\r\n\r\n🙀  "}}
{"actor":{"display_login":"BoD"}}