How to access particular fields from JSON content by using php?

i want to get the values of different fields in Json by using php


json_decode($string) will return an object from which you can get the values you assigned.

For example:

$myObject = new MyObject();
$myObject -> att1 = 5;

$string = json_encode($myObject);

//here's how you get the value:

$myJsonDecodedObject = json_decode($string);
$value = $myJsonDecodedObject -> att1;

Need Your Help

(WebApi) Can't serialize collection of objects to Json

arrays json collections

In my WebApi controller I have a few methods that return objects retrieved from a database which are serialized to Json. Everything works fine if a method serializes and returns only a single objec...

How to support only portrait mode on an iPhone app

iphone objective-c xcode autorotate device-orientation

I have a strange problem in an iPhone app I'm developing. I want my app to support ONLY portrait mode, but for some reason I can't do it (device & simulator).