How do you standardize the content returned by the interface?

Source: Internet
Author: User
Generally, the content returned by the backend includes the return code, array, and prompt information. generally, how can we name the returned array, in other words, there is more than one layer of json. Generally, the content returned by the backend includes the return code, array, and prompt information.
How do you name
In addition, the returned array is generally json once, or a layer of json

Reply content:

Generally, the content returned by the backend includes the return code, array, and prompt information.
How do you name
In addition, the returned array is generally json once, or a layer of json

Refer to the following

{Status: 1, // data Status Code: 200, // reverse Code Status Message: 'Successful ', // description information ClientTime: 1473765898, // client request time ServerTime: 1473765935, // server response time token: '38ce6474a370c3fe84ddf92403bec204cfcbe07b ', // The unique token can also be used to encrypt key data: {// json data. the format level relationship can be set as needed, although key1: value1, key2: value2, key3: {[name: 'xiaoming ', sex: 1,], [name: 'xiaohua', sex: 1,], [name: 'xiaogang ', sex: 1,]}

errNo=>errMsg=>data=>

Then the json_encode array

{    code:200,    message: "success",    data: { key1: value1, key2: value2, ... }}

Code: error code
Message: description, "success" when successful, and error
Data: the data returned when the operation is successful. the type is an object or an array.

Successful:

{"Code": "200", "data": "data is returned successfully. if no data is returned, an empty array [] is returned."}
When an error occurs:
{"Code": "Error code", "msg": "error message "}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.