Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我的 JSON 数据是这样返回的:
{"errorCodes":[0]}resultArray=[{....}]
如何获取 resultArray 作为实际的 JSON 字符串并忽略其余部分?
为什么我需要在它前面加上errorCodes?
只需使用字符串操作来摆脱所有内容resultArray=,然后使用json_decode().
resultArray=
json_decode()
$json_raw = '...'; // the raw "JSON" string $delimiter = 'resultArray='; $cleaned_json = substr($json_raw, strpos($json_raw,$delimiter) + strlen($delimiter))); $object = json_decode($cleaned_json);