私は、json文字列をクエリの応答として送信する占星術APIを使用しています。しかし、私はそれを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'] [ '状態']友達にたくさん – YvesLeBorg
感謝。出来た。 – Vivek