PHP code for JSON Payload Example
This PHP code snippet was generated automatically for the JSON Payload example.<< Back to the JSON Payload example
What is JSON?
JavaScript Object Notation (JSON) is a standard text format for storing and transmitting data over a network. API clients use the JSON format extensively to send or receive data from the server. JSON represents four primitive types (strings, numbers, boolean values, and null) and two structured types (objects and arrays). JSON file names use the .json file extension.
What is JSON Payload?
The request payload is important information in a data block that clients send to the server in the body of an HTTP POST, PUT or PATCH message that contains important information about the request. The Payload can be sent or received in various formats, including JSON. In programming, the payload is used in the context of a message protocol to distinguish between ancillary and actual data in a request. For example, request headers are required by the server to interpret and process the request from a client correctly, but they are not the request's payload. JSON syntax elements are also not a payload.
Where:
- "id": "12345" - Payload
- The rest of the information is called service data.
API Payload Formats
The following are the two types of payload:
The Payload that the client sends to the server
Where:
- "Id": 78912 and "Customer": "Jason Sweet" are Payload
The Payload returned by the server
1. The OK response Payload format:
Where:
- "success": "true" and "TotalOrders": 100 are Payload
2. The FAILED response payload format:
Where:
- "success": "false", "errorCode": 500 and "errorDescription": Invalid user ID" are Payload
JSON Payload Request Example
Example of sending JSON Payload to ReqBin echo URL:
JSON Payload Response Example
Example of server response with JSON Payload: