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 6629203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:13:37+00:00 2026-05-25T22:13:37+00:00

I have a form with inputs using this naming convetion: <input class=xxlarge name=note[url] id=url

  • 0

I have a form with inputs using this naming convetion:

  <input class="xxlarge" name="note[url]" id="url" placeholder="URL">

So, I’m using this script (found on StackOverflow) that serializes form data into JSON.

$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
    if (o[this.name] !== undefined) {
        if (!o[this.name].push) {
            o[this.name] = [o[this.name]];
        }
        o[this.name].push(this.value || '');
    } else {
        o[this.name] = this.value || '';
    }
});
return o;
};

and on the output I have this:

  {"note[url]":"URL","note[title]":"TITLE"}

I’d like to know how to transform this script to get output like this:

  {"url":"URL","title":"TITLE"}

I’m handling this from with rather standard, documented code block (using function, described above):

      $(function() {
      $('form').submit(function() {
        $('#result').html(JSON.stringify($('form').serializeObject()));
          $.post(
              "/api/create",
              JSON.stringify($('form').serializeObject()),
              function(responseText){
                  $("#result").html(responseText);
              },
              "html"
          );
          return false;
      });

Thanks in advance!

  • 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-25T22:13:37+00:00Added an answer on May 25, 2026 at 10:13 pm

    I would suggest parsing the string into a JS object, changing the keys in a for loop, then stringifying it when you’re done. Like so:

    // turn the string into a JS object
    var data = JSON.parse('{"note[url]":"URL","note[title]":"TITLE"}');
    var newData = {};
    // step through each member
    for(key in data) {
      // Regular expressions to find the brackets
      var newKeyStart = key.search(/note\[/) + 5;
      var newKeyEnd = key.search(/\]/);
      // pull out the desired part of the key
      var newKey = key.substr(newKeyStart,  newKeyEnd - newKeyStart);
      // insert into new data object
      newData[newKey] = data[key];
      }
    // turn back into JSON again
    var newJSON = JSON.stringify(newData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Codeigniter framework and I have a form with input fields. When
I have a simple form with some plain html input like bellow using ASP.NET
I have a form with a text area input. I'm using JQuery to submit
I am using ASP.NET2.0. I have created a download form with some input fields
I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9
i have the following form <form action=ManageLink method=post> <input name=artistName type=text/> <input name=songName type=text/>
I have three form inputs for people to input certain tax rates(tax_one, tax_two, sales_tax)
I am using this script to see if a user has left any inputs
If I have code like this: <form id=test_form> <input type=text value=Original value /> </form>
I have a PDF with an embedded form. This form has inputs and drop-downs.

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.