i want to get the values of different fields in Json by using php
4
-
3php.net/manual/en/ref.json.phpBoltClock– BoltClock2010-11-30 18:28:02 +00:00Commented Nov 30, 2010 at 18:28
-
1Like your other question, you'll get more help if you post some code that you're having trouble with or asking a more specific question.Jason Benson– Jason Benson2010-11-30 19:26:40 +00:00Commented Nov 30, 2010 at 19:26
-
exact duplicate of your 5 minute old question How to receive and use a json in ajax sended from php?. Are you for real?Matt– Matt2010-11-30 19:27:11 +00:00Commented Nov 30, 2010 at 19:27
-
Check out "Writing the perfect question" for help on writing questions here on SO. Language barriers may make it difficult to ask a question well, but it's worth the effort.outis– outis2010-11-30 19:48:00 +00:00Commented Nov 30, 2010 at 19:48
Add a comment
|
1 Answer
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;
3 Comments
sirin k
i tried this but doesn't work because i have a json which is a response from JSON/Atom Custom Search API.
dabito
Narrowing down your questiong or posting some code would help us give you an answer... have you tried that?
sholsinger
The JSON you're receiving is likely not well-formed. Or the data is too "deep" "NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit." use
json_last_error() as shown in the documentation to discover what went wrong during the decode.