-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,248
  • 20
  • 86
  • 174

1 Answers1

2

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

$object->property

David Nguyen
  • 8,210
  • 2
  • 30
  • 49