1

I am trying to create a json encoded array that results like this:

{
    "properties": [
        {
            "property": "email",
            "value": "[email protected]"
        }
    ]
}

This is my code:

$data = array("properties"=>array("property"=>"status", "value"=> "Pending Approval"));   
$data_string = json_encode($data, true); 

echo "<pre>";
print_r($data_string);
echo "</pre>";

Which then gives me the results of:

{
    "properties":{
        "property":"status",
        "value":"Pending Approval"
    }
}

But yet the API then responds back after a curl method that states:

Json node is missing child property

Why is the child property missing? It's been defined - what am I missing on this?

1 Answer 1

6

you are missing an array inside the properties key.

$data = array(
    "properties" => array(
        array("property" => "status", "value" => "Pending Approval"),
    )
);
//....rest of your code

properties in json appears to be an array of objects. You were providing a single object, not an array of objects.

Sign up to request clarification or add additional context in comments.

1 Comment

Good catch- I completely missed it. Indeed that was the answer. I will accept it when I can! Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.