| Author |
Retrieve and Update JSON Object Using PHP CODE
|
Arunkumar Chinnadurai
Ranch Hand
Joined: Dec 15, 2011
Posts: 53
|
|
Hai all,
I`m doing offline chat application, this application needs to work on Online and Offline. If i`m in Offline means the data are stored in localStorage after connecting Internet it synchronize with server, here i`m using php as a server side script.
The problem i need to append my json object to json file...
below i have enclosed my json file..
63_comment.json
My current JSON Object is
{"Comments": [
{"Name": "Arun", "Comment": "How to solve this problem"}]}
]
}
I need to append this commend into my 63_comment.json file...
please help me
What i have tried till now using php written here
Here i have get Json object from my file .... then how to append and store again my json file...........
Please anybody help me to out from this....
Thanks
Arun
|
 |
Nick Charles
Ranch Hand
Joined: Oct 09, 2011
Posts: 59
|
|
If you use the print_r function to find out what $obj2->Comment contains, you will see that is is an array of stdClass objects. So to add in addtional entry, create a stdClass object, set its values, and use array_push to add it to the collection. Here is an example:
P.S. I am ignoring the sytax error in your json file.
|
 |
 |
|
|
subject: Retrieve and Update JSON Object Using PHP CODE
|
|
|