Is there any standard for JSON API response format?

Yes there are a couple of standards (albeit some liberties on the definition of standard) that have emerged: JSON API – JSON API covers creating and updating resources as well, not just responses. JSend – Simple and probably what you are already doing. OData JSON Protocol – Very complicated. HAL – Like OData but aiming … Read more

What is the difference between YAML and JSON?

Technically YAML is a superset of JSON. This means that, in theory at least, a YAML parser can understand JSON, but not necessarily the other way around. See the official specs, in the section entitled “YAML: Relation to JSON”. In general, there are certain things I like about YAML that are not available in JSON. … Read more

Are multi-line strings allowed in JSON?

JSON does not allow real line-breaks. You need to replace all the line breaks with \n. eg: “first line second line” can saved with: “first line\nsecond line” Note: for Python, this should be written as: “first line\\nsecond line” where \\ is for escaping the backslash, otherwise python will treat \n as the control character “new … Read more

Use of PUT vs PATCH methods in REST API real life scenarios

NOTE: When I first spent time reading about REST, idempotence was a confusing concept to try to get right. I still didn’t get it quite right in my original answer, as further comments (and Jason Hoetger’s answer) have shown. For a while, I have resisted updating this answer extensively, to avoid effectively plagiarizing Jason, but … Read more

Parsing JSON with Unix tools

There are a number of tools specifically designed for the purpose of manipulating JSON from the command line, and will be a lot easier and more reliable than doing it with Awk, such as jq: curl -s ‘https://api.github.com/users/lambda’ | jq -r ‘.name’ You can also do this with tools that are likely already installed on … Read more

How do I get ASP.NET Web API to return JSON instead of XML using Chrome?

Note: Read the comments of this answer, it can produce a XSS Vulnerability if you are using the default error handing of WebAPI I just add the following in App_Start / WebApiConfig.cs class in my MVC Web API project. config.Formatters.JsonFormatter.SupportedMediaTypes .Add(new MediaTypeHeaderValue(“text/html”) ); That makes sure you get JSON on most queries, but you can … Read more

How to reformat JSON in Notepad++?

Update: As of Notepad++ v7.6, use Plugin Admin to install JSTool per this answer INSTALL Download it from http://sourceforge.net/projects/jsminnpp/ and copy JSMinNpp.dll to plugin directory of Notepad++. Or you can just install “JSTool” from Plugin Manager in Notepad++. New Notepad++ install and where did PluginManager go? See How to view Plugin Manager in Notepad++ { … Read more

How do I POST JSON data with cURL?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header): -H “Content-Type: application/json” Full example: curl –header “Content-Type: application/json” \ –request POST \ –data ‘{“username”:”xyz”,”password”:”xyz”}’ \ http://localhost:3000/api/login (-H … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)