json decode and get value using PHP -


I have a JSON string and I want to get value. "[Local]", "contextResponses": [{"contextElement": {"attribute": [{" Name ":" temperature "," type ":" centgread "," "" "" "" "" ":" "" "" "" "cell", "hasppattern": "wrong", "id" : "Room 1"}, "status code": {"code": "200", "dueframe": "right"}}]} ';

Here is the code which I have used, but it did not work.

  $ result = json_decode ($ s, TRUE); // Decode Jason String $ B = $ Result ['Reference Reference'] ['Reference Element'] ['Value']; // get value ???? Echo $ b; Text after the  

ContextResponses contains a numerically indexed array of only one (Item) and value property is nested more deeply than you are trying to reference (this property is within the array). It appears to be what you need:

  $ b = $ result ['contextResponses'] [0] ['contextElement'] ['attribute'] [0] ['value'];  

As you read a JSON-serialiazed data structure, you should make sure to enter it and write in each open code as [ or { This means that how you are required to refer to the items that follow you. Also, to consider using something like var_dump ($ result) in your inquiry, as It has been deserialized after you will see the structure of the data, often it comes Hane might want to make sense.

In addition, proper insanity will help when looking for something like this. Use something to copy / paste your JSON for easy refatting. You had your structure like the following, the nesting level is more easily evident.

  {"subscriptionId":. "{{Property}: [" name ":" temperature "," type ":" centigrade "," value ":" {{property} ":" local host "," contextResponses ":" [51] "Code": "200", "Reason", "Type": "Room", "isPattern": "false", "id": "cell 1"}, "status code" : "OK"}}]}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -