json standards for structure of responses
I'm trying to decide on a standard for json responses for my applications going forwards.
So I'm thinking something along the lines of
Fake Json { Message:"hello, this is a reponse", action: 0 or 1, or "Good" or "bad", statusCode: 234, }
I'm wondering if there is a good standard for this already, and also how I can keep my standards in sync between my front and back end?
Is there a clever way to do this?
I'm using a structure similar to this:
{ status: ("ok", "error" or "redirect"), message: "some message goes here.", fields: "field selectors goes here in case some highlighting is needed", url: "url to open or redirect to if needed" }
status
property is the key to tell what to do next; message
can be used to show a popup message or an inline message, etc. Can also be a list of messages separated by a '|' character to split; field
property is used to select (with jQuery or other JS library) the fields or other objects that need an action (think of this for field validation); url
property is used to change the page, open a popup or post something back, depending on your needs. 上一篇: 避免在Angular 2上记录错误
下一篇: json响应结构标准