0

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

4
  • 3
    php.net/manual/en/ref.json.php Commented Nov 30, 2010 at 18:28
  • 1
    Like 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. Commented 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? Commented 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. Commented Nov 30, 2010 at 19:48

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

3 Comments

i tried this but doesn't work because i have a json which is a response from JSON/Atom Custom Search API.
Narrowing down your questiong or posting some code would help us give you an answer... have you tried that?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.