This question has been asked earlier too, but no body has answered I guess.
Lets say mysql query returns result like following
name | id
tarun | 1
tarun | 2
tarun | 3
Now If we do standard json encode, I will get some thing like below:
[{"name":"tarun","id":"1"},{"name":"tarun","id":"2"},{"name":"tarun","id":"3"}]
But I was output something like below
[{"name" : "tarun", "ids" : [{"id": "1"},{"id": "2"},{"id": "3"}]}]
Please ignore my syntax mistakes (if any), But I hope my ques makes sense. I am using PHP as my backend scripting language.