2

I have a form that gets a data stream back from an outside server. The result returns as text that looks like JSON, but it isn't an object - is there an easy way to turn the string below into an object so I can access the info in it? Or am I just missing something REALLY simple?

Here's what I get back, and I need to get the transaction_id. Keep in mind, this is NOT an object, just a text string.

{
    "result_code":     "TargetNameExist",
    "transaction_id":  "74cdb984f9914e93acbc04579d6675ee"
}

1 Answer 1

2

Use the Json Decode function:

json_decode ( string $json )
Sign up to request clarification or add additional context in comments.

1 Comment

THANKS! I know it was simple... I was able to access the individual variable like this: $jtest = json_decode ( $response->getBody(), true ); echo "transaction_id=" . $jtest['transaction_id'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.