1

I want to decode json string in Php that is pass from android.

Suppose i have follwing json that comes from android
{"name":"ajay"} and in php i do

<?php
$result=json_decode('$_POST',true);
$name=$result['name'];
$response=array();
$response["message"]=$name successfully parse in php;
echo json_encode($response);
?>

This gives html tag in response.Is there is any way to solve this?

2

2 Answers 2

3

Follow this link. Maybe this will be helpful:

http://www.php.net/manual/en/function.json-decode.php

Sign up to request clarification or add additional context in comments.

2 Comments

Can you be a little descriptive.. Don't post only a link as answer. You must explain the answer. or add a comment to the answer
Link-Only-Answers are not answers because the information might get lost if the link dies.
1

This seems working fine for me

<?php
  $result=json_decode('{"name":"ajay"} ',true);
  $name=$result['name'];
  $response=array();
  $response["message"]="$name successfully parse in php";
  echo json_encode($response);
?>

Check php manual for json_decode for more

3 Comments

This gives html tag in response
You paste the code and run it. I dont get any html tag in the output for the above code. It will give you {"message":"ajay successfully parse in php"} as the output. May be you are modifying the output. If so post the code you are trying
I am passing json string from android to Php.But i could not get JSON string in php.Could you please help me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.