Android Question JSON newbie has a question

mcorbeel

Active Member
Licensed User
Longtime User
So, I just started with JSON and have a question. My app connects to a server. The server answers with 1 response.
The response starts with:

{"logon":[{"error":"","username":"Some Name","firstdayofweek":"mon"}]}

or

{"logon":[{"error":"You have no access to this blablabla","username":"","firstdayofweek":"mon"}]}

if the user has no access.

Here I can tell if the user is granted access or not. Parsing this with JSON works, so far so good. But if the user is granted access, the response will also contain calendar items, as in this example:

{"logon":[{"error":"","username":"Some Name","firstdayofweek":"mon"}]},{"bookings":[{"detail id":"26503","bookingday id":"9693","booking id":"2760","desc":"Blazhoffski\Semi-Live Singer- Songwriter 2013, Technische meeting, Production","date":"20131018","from":"201310181400","till":"201310181700","clock":"red"},{"detail id":"21622","bookingday id":"9011","booking id":"2444","desc":"Studio A nv / TvBastards\Jupiler League '13 - '14, Foot Matchday 11, BASIS : Standard - Charleroi ( 14:30) Franse Master, Production","date":"20131020","from":"201310200730","till":"201310201930","clock":"gray"},{"detail id":"21090","bookingday id":"8911","booking id":"2410","desc":"Woestijnvis nv\De Ideale Wereld, Opnamen, Production","date":"20131021","from":"201310211500","till":"201310211900","clock":"gray"},{"detail id":"21094","bookingday id":"8912","booking id":"2410","desc":"Woestijnvis nv\De Ideale Wereld, Opnamen, Production","date":"20131022","from":"201310221500","till":"201310221900","clock":"gray"},{"detail id":"23718","bookingday id":"9418","booking id":"2618","desc":"Outside Broadcast\Divers 2013, Meeting Audio, Production","date":"20131024","from":"201310240930","till":"201310241230","clock":"gray"},{"detail id":"23591","bookingday id":"0","booking id":"0","desc":"Vrij Weekend","date":"00010101","from":"201310260000","till":"201310270000","clock":"gray"},{"detail id":"23591","bookingday id":"0","booking id":"0","desc":"Vrij Weekend","date":"00010101","from":"201310270000","till":"201310280000","clock":"gray"}]}

So after I read the logon fields, I want to read the calendar items but this doesn't work, tried al sorts of things. I doubt if this is the proper way to do it? Can someone help me out with this?
 

mcorbeel

Active Member
Licensed User
Longtime User
If I check only the calendar items:

{"bookings":[{"detail id":"26503","bookingday id":"9693","booking id":"2760","desc":"Blazhoffski\Semi-Live Singer- Songwriter 2013, Technische meeting, Production","date":"20131018","from":"201310181400","till":"201310181700","clock":"red"},{"detail id":"21622","bookingday id":"9011","booking id":"2444","desc":"Studio A nv / TvBastards\Jupiler League '13 - '14, Foot Matchday 11, BASIS : Standard - Charleroi ( 14:30) Franse Master, Production","date":"20131020","from":"201310200730","till":"201310201930","clock":"gray"},{"detail id":"21090","bookingday id":"8911","booking id":"2410","desc":"Woestijnvis nv\De Ideale Wereld, Opnamen, Production","date":"20131021","from":"201310211500","till":"201310211900","clock":"gray"},{"detail id":"21094","bookingday id":"8912","booking id":"2410","desc":"Woestijnvis nv\De Ideale Wereld, Opnamen, Production","date":"20131022","from":"201310221500","till":"201310221900","clock":"gray"},{"detail id":"23718","bookingday id":"9418","booking id":"2618","desc":"Outside Broadcast\Divers 2013, Meeting Audio, Production","date":"20131024","from":"201310240930","till":"201310241230","clock":"gray"},{"detail id":"23591","bookingday id":"0","booking id":"0","desc":"Vrij Weekend","date":"00010101","from":"201310260000","till":"201310270000","clock":"gray"},{"detail id":"23591","bookingday id":"0","booking id":"0","desc":"Vrij Weekend","date":"00010101","from":"201310270000","till":"201310280000","clock":"gray"}]}

then it seems to be OK. But I have to put one record in front to check the credentials. I hoped that I could just add it separated with a comma, but this doesnt seem to work. Is there another way of doing this?
 
Upvote 0

mcorbeel

Active Member
Licensed User
Longtime User
In asp.net (VB). Meanwhile I found a solution. My response is now 2 lines (delimited by CRLF). The first is always the login info, the second is the JSON string. Problem solved!
 
Upvote 0
Top