我正在使用占星术API发送一个json字符串作为对查询的响应。但我一直试图将其转换为json并从响应字符串中检索不同的项目。下面是响应的例子:获取json字符串元素
{"ashtakoota":{"status":true,"received_points":26},"manglik":{"status":true,"male_percentage":13.25,"female_percentage":13.75},"rajju_dosha":{"status":false},"vedha_dosha":{"status":false},"conclusion":{"match_report":"Marriage between the prospective bride and groom is highly recommended. The couple would have a long-lasting relationship, which would be filled with happiness and affluence."}}
我使用PHP脚本,所以我尝试了下面的代码:
$json = json_decode($res1, true); TRY 1 --> echo array_values($json[1]); TRY 2 --> echo $json.ashtakoota.status; TRY 3 --> echo $res1.ashtakoota.status;
但产量始终是空白。我怀疑$ json是空的还是json响应不是完美的json。
尝试4:$ json ['ashtakoota'] ['status'] – YvesLeBorg
非常感谢朋友。有效。 – Vivek