The problem your having is this string is NOT Proper JSON: [500,'hello world']

this would be proper JSON [500,"hello world"]. JSON is very strict on formatting and requires that all string values be wrapped in double quotes and NEVER single quotes.

the proper thing to do to avoid problems, would be to use the php functions json_encode() and json_decode()

for example,

<?php
    $myarray[] = 500;
    $myarray[] = "hello world";
    $myjson = json_encode($myarray);
?>
<form name="input" action="post.php">
    <input type="hidden" name="json" value="<?php echo $myjson ?>" />
    <input type="submit" value="Submit">
</form>

and in the post.php you would read it like so,

<?php
    $posted_data = array();
    if (!empty($_POST['json'])) {
        $posted_data = json_decode($_POST['json'], true);
    }
    print_r($posted_data);
?>

the true flag in json_decode() tells the function you want it as an associative array and not a PHP object, which is its default behavior.

the print_r() function will output the php structure of the converted JSON array:

Array(
    [0] => 500
    [1] => hello world
) 
Answer from Sheac on Stack Overflow
🌐
SitePoint
sitepoint.com › javascript
Getting contents of a JSON array into PHP as part of a $_POST array
August 23, 2018 - As an alternative to sending the arrays encoded as form values, as ScallioXTX suggests, you can also send the JSON as a POST request with the content-type application/json. When you send JSON to PHP in this way, it won’t be available via the $_POST superglobal.
Discussions

get POSTed JSON Array in php
How can I send a POST request along with a JSON array to main.php to return the value of key_1? My current method below doesn't work and I can't figure out how to fix this. script.js: var array =... More on stackoverflow.com
🌐 stackoverflow.com
February 27, 2019
jquery - JSON Post and Decode array to PHP - Stack Overflow
I'm tring to post an array to PHP file using JSON. It does not work. The problem is nothing happens. If I decomment datatype:"json" then I get the alert (but without data). This is my jquery code... More on stackoverflow.com
🌐 stackoverflow.com
August 21, 2013
Send JSON string (array) from Javascript to PHP via POST - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. for hours I try to find a simple solution to send a ready JSON string to a PHP method. More on stackoverflow.com
🌐 stackoverflow.com
April 1, 2017
send JSON or array to submit POST (jQuery -> PHP)
Good morning. I'm stucked on this thing: I'm doing a form (which send info to other page via submit button, post) which dynamically user can add some other form-groups with a button. Ok, that's eas... More on stackoverflow.com
🌐 stackoverflow.com
July 20, 2017
🌐
Quora
quora.com › How-do-I-send-a-JSON-array-in-a-post-request
How to send a JSON array in a post request - Quora
Answer (1 of 4): What you need to do is to proceed with these steps: 1. Create the JSON Array: First, you need to create the JSON array that you want to send in your POST request. Make sure the data is properly formatted as a valid JSON array. 2. Set Headers: In your POST request, you'll need to...
🌐
Stack Overflow
stackoverflow.com › questions › 43154632 › send-json-string-array-from-javascript-to-php-via-post
Send JSON string (array) from Javascript to PHP via POST - Stack Overflow
April 1, 2017 - Copy$data = json_decode(file_get_contents('php://input'), true); echo $data; without success. I think $data is NULL. I tried this: ... Copy[{\“id\“: 110, \“teamname\“: \“first\“}, {\“id\“: 140, \“teamname\“: \“second\“}] Which can't be used as string in json_decode. The main problem is, that I don't know which part is wrong... Thanks for helping ... if you put $_POST['teams'] on json_decode() then its fixed the problem!
🌐
Stack Overflow
stackoverflow.com › questions › 45210258 › send-json-or-array-to-submit-post-jquery-php
send JSON or array to submit POST (jQuery -> PHP)
July 20, 2017 - <?php header("Content-type: application/json"); $first = $_POST['first']; $last = $_POST['last']; $arr = ['first' => $first, 'last' => $last]; echo json_encode($arr); ?> ... that's an approaching what I want.
Find elsewhere
🌐
PHPpot
phppot.com › php › php-curl-post-json
PHP Curl POST JSON Send Request Data - PHPpot
This is to handle the JSON data posted via PHP cURL in the API endpoint. It used json_decode to convert the JSON string posted into a JSON object. In this program, it sets “true” to convert the request data into an array.
🌐
Coderwall
coderwall.com › p › ywtneg › pass-array-through-post-method
Pass array through POST method (Example)
January 4, 2021 - How to pass an array using POST method. First use the function json_encode() to encode the array. Then use htmlspecialchars() to avoid errors caused by the quotes in json.
🌐
Apidog
apidog.com › blog › php-post-json
Posting JSON Data with PHP: A Practical Guide
json_decode(): Conversely, this function is used to convert a JSON string into a PHP array or object. These two functions will be our best friends throughout the JSON posting process. Posting JSON data with PHP typically involves using the cURL library or PHP’s built-in functions to send an HTTP POST request.
🌐
SitePoint
sitepoint.com › php
Submitting JSON via POST in PHP? - PHP - SitePoint Forums | Web Development & Design Community
May 4, 2009 - The kiosk interface is flash based. So the process is something like so: actionscript submits post array (via ajax call) to —> php and curl —> curl then sends to client website for processing.
🌐
Make Community
community.make.com › questions
Post an array in a HTTP request - Questions - Make Community
June 8, 2023 - $response = $client->post(‘https://www.lioren.cl/api/boletas’, [ ‘headers’ => [ ‘Accept’ => ‘application/json’, ‘Authorization’ => 'Bearer '.$accessToken, ‘Content-Type’ => ‘application/json’ ], ‘body’ => json_encode($data), ]); $responseBody = json_decode((string) $response->getBody(), true); I have tried different configurations and I get a Status code 200 but with an error that says “emisor must be an array” (I believe an array).
🌐
Bubble
forum.bubble.io › need help › apis
POST Request: dynamically send an array (list) in a JSON - APIs - Bubble Forum
February 7, 2022 - Hey everyone, I need to send a POST Request to an API. This post request contains a field “envs”, which contains an array of objects (each of those contains a “key” and a “value” - both strings) (See screenshot). I cannot simply hardcode this information into the request.
🌐
LornaJane
lornajane.net › posts › 2011 › posting-json-data-with-php-curl
POSTing JSON Data With PHP cURL
November 22, 2011 - Instead, we create the correct JSON data, set that as the body of the POST request, and also set the headers correctly so that the server that receives this request will understand what we sent: $data = array("name" => "Hagrid", "age" => "36"); ...
🌐
Robert Price
robertprice.co.uk › home › posting json to a web service with php
POSTing JSON To A Web Service Using PHP - Robert Price -
May 31, 2017 - When POSTing JSON to a RESTful web service we don’t send post fields or pretend to be a form, instead we have to send the JSON data in body of the request, and let the web service know it’s JSON data by setting the Content-type header to application/json.
🌐
Write
write.corbpie.com › how-to-post-json-data-with-php
How to POST JSON data with PHP - write
April 20, 2021 - $url = 'https://domain.com/folder/post_data.php'; $data = json_decode(file_get_contents("https://age-of-empires-2-api.herokuapp.com/api/v1/civilizations"), true); $crl = curl_init($url); curl_setopt($crl, CURLOPT_POST, 1); curl_setopt($crl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($crl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($crl); echo $result; The file that receives the POST request and the data (post_data.php):