开发者

How to post NSArray using JSON in Objective C

开发者 https://www.devze.com 2023-04-05 07:23 出处:网络
I am developing one app. I want to post NSArrays to webservice that save array data in db. I am right now using JSON API in my iphone app.

I am developing one app. I want to post NSArrays to webservice that save array data in db.

I am right now using JSON API in my iphone app.

I seek help about how to post nsarrays as i could not find any way to post array data.开发者_开发问答

THanks in advance.


Here i am using sbjon

  #import "SBJSON.h"
  #import "JSON.h"


    SBJSON *jparser = [[SBJSON new] autorelease];

    NSString *jsonItems = [jparser stringWithObject:self.urArray];



    NSString *userlogin_id=@"AppleVijay";
    NSString *venue_id=@"India";


    NSString *postString =[NSString stringWithFormat:@"userlogin_id=%@&venue_id=%@&items=%@",userlogin_id,venue_id,jsonItems];

    NSURL *urURL=[NSURL URLWithString:@"AppleVijay@facebook.com"];


    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:urURL];

    [request setHTTPMethod:@"POST"];

    [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];



    NSURLConnection *connection=[[NSURLConnection alloc]
                                 initWithRequest:request delegate:self];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号