2

I'm setting up a json-over-http service. The responses should have some meta-data, primarily for success/failure. That could be done via http headers, but putting it in the json is nicer (it makes the meta-data available even if some higher-up part of the client code has consumed the http response object).

Is there an emerging standard for this?

I'm aware of JSend, but it doesn't seem to have widepsread adoption.

JSend, in a nutshell, is:

{
status: "success"|"fail"|"error", 
message: String, // optional error message 
data: any, // the ajax payload
code: Number // optional numeric code for errors
}
Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41

1 Answers1

3

My conclusion is: JSend is the most widely adopted wrapper format for json responses, so that is the way to go.

Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41