I am sending a json object from java to php. I am using gson in java side which sends json as an object:
Java code:
Fruit fruit = new Fruit();
fruit.setFruidId(6);
fruit.setAvailable("yes yes");
Gson gson = new Gson();
String json = gson.toJson(fruit);
This json string look like this
{"fruidId":6,"available":"yes yes"}
Using java side I can retrieve the json data as an object like this
Gson gson = new Gson();
Fruit a = gson.fromJson(json, Fruit.class);
System.out.println(fruit.getFruitId());
I want to retrieve the data in php as an object; like the one I have done using java.
Is it possible to do it like this? Please show me the way.
Use json_decode with the 2nd paramater as
falseto set to an object ortrueas an array.