JSon mismatch between .net and swift 2 -


i have build asp.net webapi export data in json format. in ios 9 app (swift 2) try load data doesn't work.

i think has todo structure/format of json data. sample https://api.kivaws.org/v1/loans/newest.json works fine load in app. loans json data starts with:

{ "paging": { "page": 1, "total": 3699, "page_size": 20, "pages": 185 },
"loans": [ { "id": 1012426, "name": "arati", "description": { "languages": [ "en" ] },

my json data starts with:

[ { "id": 5, "name": "test", "createdate": "2015-04-04t20:28:07", "changedate": "2015-05-06t15:09:06.18" }, ....continues more items

in swift code

nsjsonserialization.jsonobjectwithdata(data, options: nsjsonreadingoptions.mutablecontainers) as? nsdictionary

it find 2 keys (paging , loans) in dictionary loan json. json dictionary ends nil.

i see difference in json format/structure. how webapi export json data similar to:

{ "items": [ { "id": 5, "name": "test", "createdate": "2015-04-04t20:28:07", "changedate": "2015-05-06t15:09:06.18" }, ....continues more items

in asp.net code have apicontroller following method:

public ienumerable get() {
list list = ....getting data
return list
}

or can in swift read json in way works?


Comments