zoukankan      html  css  js  c++  java
  • iOS对象(数组)转化为JSon字符串

    - (void)seabc

    {

        NSArray *arry=[NSArray arrayWithObjects:@"0081",@"0082",@"0083", nil];

        NSString *ss = [self objArrayToJSON:arry];

        NSString * datsa = [NSString stringWithFormat:@"pictures=%@",ss];

        NSLog(@"jsonStr==%@",datsa);

     

        NSString *url = [NSString stringWithFormat:@"http://app.y-x-q.cn/index.php/interfaces/Articleapi/test1"];

        

        [RequstHttp postWithPathURL:url params:datsa succes:^(NSData *json) {

            NSLog(@"json:%@",[[NSString alloc]initWithData:json encoding:NSUTF8StringEncoding]);

        } failure:^(NSError *error) {

        }];

        

    }

     

    //把多个json字符串转为一个json字符串

    - (NSString *)objArrayToJSON:(NSArray *)array {

        

        NSString *jsonStr = @"[";

        

        for (NSInteger i = 0; i < array.count; ++i) {

            if (i != 0) {

                jsonStr = [jsonStr stringByAppendingString:@","];

            }

            jsonStr = [jsonStr stringByAppendingString:array[i]];

        }

        jsonStr = [jsonStr stringByAppendingString:@"]"];

        

        return jsonStr;

    }

  • 相关阅读:
    python中unicode、utf8、gbk等编码问题
    git常用操作
    python List&Set&Dict交集、并集、差集
    VIM的高级使用
    Logger级别和输出的地方
    Eclipse+pydev 常用快捷键
    架构相关领域的学习材料(转)
    深入浅出之正则表达式(一)
    深入浅出之正则表达式(二)
    软件project总结
  • 原文地址:https://www.cnblogs.com/shenlaiyaoshi/p/7776784.html
Copyright © 2011-2022 走看看