Are there any popular best practices for designing the JSON data format returned by the API interface?

recently, our company has developed a project. Are there any popular best practices for designing the JSON data format returned by the API interface for PC-based mobile phones and APP-based mobile web pages?

the following versions have been found

version 1:: head Status Code:2XX executed successfully

json {"id": 51, "age": 58, "name": "lifei"}

failed to execute head Status Code:4XX-5XX {"message": "xxxxxx error", "errors: {}}

"

version 2: success and failure execute head Status Code:2xx

json {"code": "0", "message:" Information, "data": {}}

version 3:: head Status Code:2XX executed successfully

json {"id": 51, "age": 58, "name": "lifei"}

failed to execute head Status Code:4XX-5XX {"code": 10001, "message": "xxxxxx error", "errors: {}}

"

if there are different types of errors in the business, such as when I want to withdraw cash, there may be errors such as unbound bank card, not uploading hukou book, not uploading ID card, not binding mobile phone number, not entering address, no balance, and so on.


this

JSON RPC 2.0
http:// Www.jsonrpc.org/specif.


which one is the last one used by the landlord?

Menu