I have following table in mysql. 1)User
userid username college
1 robert sarauniversity
2 albert oxford
2)UserDetails
userid subjectid
1 1
1 2
2 3
1 4
2 1
3)subjectdetails
subjectid subjectname subjectteacher
1 basic science pro. vengaskar
2 advance mathematics pro. richard
3 history pro. michale
4 geography pro. renuka
I need following data in json
[
{
id:1
username:robert
subjects:[
{
subjectname:pro. geography ,
subject teacher:algebra
},
{
subjectname:pro. vengaskar,
subject teacher:pro. renuka
}
]
},
{
id:2
username:albert
subjects:[
{
subjectname:history ,
subject teacher: pro. michale
},
{
subjectname:basic science,
subject teacher: pro. vengaskar
}
]
}
}
I have developed json rest api several times but this time it is json array with object which have json array. I ma confused how to iterate content and get final desired json. I am not pasting php code as nothing going to help me. so sad it took my two days but still at beginning...
id:1in your JSON Format ?