neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.36k stars 267 forks source link

trailing comma #146

Open Lindfeldto opened 5 years ago

Lindfeldto commented 5 years ago

Testing the lib and as a freak accident I used the JSON from: https://developers.google.com/search/docs/guides/intro-structured-data The trailing comma here after "43 g" causes an exception. JsonParsingException: 'expected:'String Begin Token', actual:'}', at offset:720'

{
    "@type": "NutritionInformation",
    "servingSize": "1 medium slice",
    "calories": "230 calories",
    "fatContent": "1 g",
    "carbohydrateContent": "43 g",
  }

I am aware that trailing comma is not in the JSON standard, at the same time it is accepted by other parsers like Json.net and also given in an example by Google. Maybe you want to consider it. It's a potential problem in public/integration API's when you don't control what the client sends.