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

  • SEARCH
  • Home
  • 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 6122239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:52:32+00:00 2026-05-23T15:52:32+00:00

I am trying to submit some JSON to my web app and I want

  • 0

I am trying to submit some JSON to my web app and I want the JSON to be like this:

{ 
  "thing1" : 
  {
    "something" : "hello"
  },

  "list_of_things" :
  [
   {
     "item1" : "hello"
   },
   {
     "item2" : "hello"
   }
  ]
}

Here I have one JSON object and a JSON array that holds JSON objects. When I create the data to submit in Javascript I do:

form = {
  "thing1" : {
    "something" : somethingVariable
  },
  "list_of_things" : listArray
}

Here ‘listArray’ is a Javascript Array object of Javascript hash objects. I submit this using jQuery’s ajax method but instead of javascript array displaying as the JSON array desired it converts it to a series of JSON objects like this:

{ "1" : { "thing1" : "something" }, "2" : { "thing2" : "something" }...

How can I get the array to be submitted as an array rather than be converted into a series of JSON objects with the array indexes as keys?

EDIT#1: ‘listArray’ is a simple Javascript array that is defined like so:

var listArray = new Array();
listArray.push({ "thing1" : "something" });
listArray.push({ "thing2" : "something" });

EDIT#2: ‘form’ is sent to the server with the following call:

$.ajax({
  type: 'POST',
  url: '/url',
  dataType: "json",
  data: form,
  success: function(data) {
    /* success code here */
  }
});
  • 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-05-23T15:52:33+00:00Added an answer on May 23, 2026 at 3:52 pm

    Have a look here. If you are truly trying to post JSON you will need to send the string, not an object literal. You could use JSON.stringify (or a more supported JSON solution) on form.

    $.ajax({
        url: "/url",,
        dataType: "json",
        type: "POST",
        processData: false,
        contentType: "application/json",
        data: JSON.stringify(form)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to submit an update to my app. I had messed up some
I'm trying to submit some JSON to an OData service. According to the $metadata,
I'm trying to POST some json to a web service that accepts json. The
I'm trying to submit a Rails form with AJAX. I have some toggle on/off
I'm trying to submit a Mac app for Approval in the App Store, but
I am trying to submit an array in MonoTouch to a vb.net web service.
Trying to create and submit form within a javascript call. This code works fine
Hello I'm trying to dynamically generate some inputs for my form, but it's not
I am trying to submit a form using jQuery's .ajax() function. It seems like
I'm trying to submit a form using javascript. This is the code I've used

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.