In a plugin, How to update a json file using ajax

Here is your main problem: chemin = plugin_dir_url( __FILE__ ) . “inc/json/notes.json”; There are 5 critical mistakes in the code: file_get_contents requires a file path, but you’re asking for a URL by using plugin_dir_url, not all servers support remote URLs in file_get_contents for security reasons, and if they do, this would be a big performance … Read more

how to create JSON array [] for REST response?

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”: … Read more