How to convert JSON string to array

后端 未结 14 914
猫巷女王i
猫巷女王i 2020-11-22 03:37

What I want to do is the following:

  1. taking JSON as input from text area in php
  2. use this input and convert it to JSON and pass it to php curl to send
14条回答
  •  被撕碎了的回忆
    2020-11-22 04:07

    If you pass the JSON in your post to json_decode, it will fail. Valid JSON strings have quoted keys:

    json_decode('{foo:"bar"}');         // this fails
    json_decode('{"foo":"bar"}', true); // returns array("foo" => "bar")
    json_decode('{"foo":"bar"}');       // returns an object, not an array.
    

提交回复
热议问题