如何在OBJ c中解析这个JSON

时间:2016-02-08 22:47:44

标签: objective-c json

我从网络进程

收到此JSON字符串
gulp.task('default', function() {
  return gulp.src(files, { base:'./' })
    .pipe(rename(function(path) {
      path.dirname = path.dirname.replace(/(.*)?\/images\/?/, '');
    }))
    .pipe(gulp.dest('public_html/assets/images/'));
});

当我使用以下内容获取数据时:

{
   "result":"ok",
   "description":"",
   "err_data":"",
   "data":[
      {
         "id":"14D19A9B-3D65-4FE2-9ACE-4C2D708DAAD8"
      },
      {
         "id":"8BFD10B8-F5FD-4CEE-A307-FE4382A0A7FD"
      }
   ]
}

它记录为:

NSError *jsonError = nil;
NSData *objectData = [ret dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json= [NSJSONSerialization JSONObjectWithData: objectData options:kNilOptions error: &jsonError];

NSLog(@"data: %@",[json objectForKey:@"data"]);

如何使用值和键将数据解析为NSDictionary?

1 个答案:

答案 0 :(得分:1)

Web返回一个具有属性的对象,该属性是一个对象数组,所以......

function loop(){
    if(check > 0){
      check++;
    }
    if ( (check===0) || (check===3) {
       check = 0;
       document.write("doing something every 1sec");
    }
}