Convert php / string to json and get value

Asked 1 years ago, Updated 1 years ago, 63 views

{"message":{"@type":"response","@service":"naverservice.labs.api","@version":1.0.0,"result":{"translatedText":"I go to school.","srcLangType":"en"}

I would like to extract 'I go to school' from the result value received after API request When I use var_dump, it says string json_code, json decode is not allowed Please reply. <

php json

2022-09-22 18:28

1 Answers

It's working Is there an error message?

$jsonString = '{"message":{"@type":"response":"@service":"naverservice.labs.api":"1.0.0","result":{"translatedText":"I go to school":"srcType":}
$object = json_decode($jsonString);
var_dump($object->message->result->translatedText); // string(24) "I go to school."


2022-09-22 18:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.