


We can just queue it and let our background services do further validation of the data later. When using something like ASP.NET Web API, don’t define your methods expecting specific classes as incoming data and instead read the post body so ASP.NET never parses the JSON.įor Stackify’s services we use header values for authentication, so in some scenarios, we never even need to analyze the body of the message. For web apps that receive JSON and simply write it to a queue, database, or other storage, try not to ever parse the JSON if you can. This may seem obvious, but it necessarily isn’t. So use gzip wherever possible when communicating with your web services. Since JSON is just simple text, you can expect to get up to 90% compression. Improved Performance using JSON Streaming This is a little more efficient and preferred where possible. Most JSON parsing libraries can read straight from a stream instead of a string. I haven’t tested it myself but I have also heard good things about Jil which is designed entirely for speed by StackExchange’s team. Overall most features and flexibility: Json.NET Here are my results from doing some simple benchmarks from a test app ( View on GitHub). If you do a lot of parsing and really care about performance, FastJsonParser is a lot faster than anything else I have tried. This is based on my own testing and I encourage you to do the same. But ServiceStack, FastJsonParser () and even the built in DataContractJavascriptSerializer may be faster or provide specific features you may need depending on the scenario. In ASP.NET the most popular JSON library is Json.NET (Newtonsoft). You may need multiple JSON libraries for optimal performance and features NET for most of our services, most of these tips apply to other programming languages as well.

We have compiled a list of some common JSON performance tips.
PHP JSON DECODE ATTRIBUTES CODE
Although originally derived from the JavaScript scripting language, JSON is now a language-independent data format and code for parsing and generating JSON data is readily available in many programming languages.Īt Stackify, we use JSON extensively for REST APIs, serializing messages to queues, and much more. JSON is easy to work with and has become the standard data format for virtually everything.
