-1

I have a string that looks like this:

{"red":216.77,"blue":0.669,"green":0.545,"alpha":1}

I want to save it in either an array like this:

array(
  "red" => 216.77,
  "blue" => 0.669,
  green" => 0.545,
  "alpha" => 1
)

or some other structure (like stdclass) containing name-value pairs, so that I can traverse it and retrieve values by names.

How can I do that?

Solace
  • 8,612
  • 22
  • 95
  • 183

1 Answers1

2

$object = json_decode("JSON response goes here")

$object->property

David Nguyen
  • 8,368
  • 2
  • 33
  • 49