Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:29:57+00:00 2026-06-15T03:29:57+00:00

I want to post an array value in JSON. Below is my code :

  • 0

I want to post an array value in JSON.

Below is my code :

-(void)getConnection {

    NSArray *comment=[NSArray arrayWithObjects:@"aaa",@"bbb",@"ccc",@"hello,yes,tell", nil];

    NSURL *aurl=[NSURL URLWithString:@"http://sajalaya.com/taskblazer/staffend/form/iphonearraytest.php"];

    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:aurl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

    [request setHTTPMethod:@"POST"];

   NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:comment options:NSJSONWritingPrettyPrinted error:nil];
   NSString *new = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];

 // NSString *new = [comment JSONString];

 // NSArray *new=[comment jsonvalue];

    NSString *postString=[NSString stringWithFormat:@"tag=&comment=%@&total=%@",new,@"4"];

    NSLog(@"this is post string%@",postString);
    [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

     [NSURLConnection connectionWithRequest:request delegate:self];       
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:29:59+00:00Added an answer on June 15, 2026 at 3:29 am

    We don’t know your question, but my answer is short and simple. You should use great open source library for this, which is: AFNetworking, and do request like this:

    _httpClient = [[AFHTTPClient alloc] initWithBaseURL:[[NSURL alloc] initWithString:@"http://sajalaya.com"]];
    
    [_httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
    
    NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:comment options:NSJSONWritingPrettyPrinted error:nil];
    NSString *new = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
    
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            new, @"comment",
                            @4, @"total,
                            nil];
    
    NSMutableURLRequest *request = [self.httpClient requestWithMethod:@"POST"
                                                                 path:@"/taskblazer/staffend/form/iphonearraytest.php"
                                                           parameters:params];
    request.timeoutInterval = 8;
    
    AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:request];
    
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 
          // success
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          // failure
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the value of json array using .each here's where I
I want to retrieve array value. This is my array value: overlay.txt: {title:sss,description:sss,code:sss} {title:trtr,description:trtr,code:tyrytr}
I simply want to post an image and comment from my own site to
I can successfully post an array to PHP using Ajax Post but I want
i want to send an array to php via Ajax Json, but i cant
I want to pass a JSON: {name:jason,age:20} in PHP though POST In RoR, I
I want to pass arrays in the jquery $.post() request. HTML: <input type=checkbox id=add-check-1e30>
I want to post a forma poupup window. Problem is, the form posts successfully
I want to post some data to a file via ajax when somebody clicks
I want to post in memory some child rows, and then conditionally post them,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.