Just use another array()
inside user array()
$response = array();
$response[] = array(
'version' => '1.0',
'user' => array(
array(
'first_name' => 'Razon',
'last_name' => 'komar pal',
'email' => '[email protected]',
'id' => 10,
)
),
);
return rest_ensure_response($response);
It will output like:
[
{
"version": "1.0",
"user": [
{
"first_name": "Razon",
"last_name": "komar pal",
"email": "[email protected]",
"id": 10
}
]
}
]
Hope this will work for you 🙂
Related Posts:
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Is there a way I can fetch the WordPress Developer Code References with an API?
- How to receive JSON payload from a digital device
- WordPress API “code”:”rest_no_route” with Custom Route
- Autotrader API Integration
- REST API get featured image source for custom post type
- WP REST API only returning partial list of users
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- WordPress Rest API: How do we validate with our custom API key?
- authentication issue with rest api – rest_cannot_create
- wordpress wp-json prefix issue
- Implementing the wp json-rest api
- x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
- Can’t GET draft posts via REST API from headless frontend
- Increase the page size of the WordPress REST API
- Formating content rendered from wordpress REST API as JSON and not HTML
- Options to get my custom post type metadata via the WordPress API
- Keep user’s privileges on accessing contents in JSON response
- WordPress REST API – Modify JSON before importing
- How can I cache WordPress Rest API Response
- Passing a borrowed nonce through Postman fails
- Why does AWStats show /wp-json* as Viewed URLs
- Why aren’t tags and categories added in post request to WP Rest API
- How send get request to external api with username and password
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- Get all PDF files from page with WordPress API
- How to order WordPress Rest API data
- WP Rest API – How to convert embedded to json object in Java [closed]
- featured image not found in json from wp rest api
- WordPress REST API not returning all posts
- Custom endpoint to get all custom taxonomy terms
- WordPress JSON data to and from database to be shown on rest point
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- How to Get Featured Image from REST API?
- body_class REST field in WP-API
- Validate rest-api call on create
- If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?
- Get a remote post ID via API given URL
- How to connect android app with WordPress website?
- How to change the date and time in REST API for comments?
- Custom WP API endpoint NULL body data
- WordPress HTTP API NTLM Authentication
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- REST API and filtering by meta value
- Rest API: trouble receiving response through script (browser and Postman display correctly)
- How to clone all WordPress Rest API end points
- 403 error when publishing a post in wordpress. Error => Publishing failed. The response is not a valid JSON response
- how to use nimble-API and Display data?
- Error message: Response is not a valid JSON response
- WordPress REST API not working on localhost
- How to display relations via wordpress Rest API
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- DELETE request using WP REST API
- Can I overwrite default WordPress Json API For no more pages text
- trigger WordPress rest any API call
- Secure WordPress API, how?
- register/login api
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- WP Rest API in Android studio does not show Images
- What’s the right way to validate JSON data coming from an AJAX POST request?
- Remove unwanted fields from WP API response
- exclude particular category in api
- How do i POST to WordPress rest API from the same domain?
- WP CLI in WP 5.3 with PHP 7.4
- The REST API encountered an error in wordpress?
- Get wordpress post with featured image, category and tag from WordPress API
- WordPress output data to another website and pull data
- Loop through WordPress API response errors
- Connecting WordPress with an External API
- WordPress single page website redirect to index.html
- Rest WP_Error always return null
- Fix Characters WordPress Ionic App
- I would like to retrive JSON value and display it in wordpress page or widget
- Display Post Featured Image along with Categories via WP Rest API
- Why does “if statement” has to “die()”, otherwise wont work?
- How to create REST Based JSON API(how to modify the code below)?
- Best way to make a JSON API from WordPress?
- WordPress REST API not displaying all information
- WordPress Rest API Escapes Returned URLs Forward Slash
- Custom WP Rest API Endpoints from JSON Schema
- Update post / page using API + python
- Custom rest api endpoint response json problem
- WordPress json – How to use the content rendered from json
- JS WordPress API fetch no response headers
- Issue with API after 6.2 update
- Woocommerce API for calling products by Category ID
- Why is my custom API endpoint not working?
- WP Rest API v2 filter and display latest post with specific tag
- WP Rest API v2 return posts with specific tag
- Hiding API routes list
- How to get around WP REST API per page limit without pagination?
- WordPress doesn’t send a notification email when submitting a comment using REST API
- Using WordPress RESTapi to call a php file instead of post or page
- pagination in WP rest api
- How to post an unserialized array via wordpress rest API as meta data
- merge wp rest api query to get posts per category does not work
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- Rest Api fetching only one random post
- Access featured image URL based on media ID?
- Call to undefined function upload_is_user_over_quota()