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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:58:43+00:00 2026-06-12T15:58:43+00:00

I have the following jquery – var items = new Array(); items.push({ Item1:$(myvalue).val(), Item2:$(myvalue2).val()

  • 0

I have the following jquery –

var items = new Array();
   items.push({
    "Item1":$("myvalue").val(),
    "Item2":$("myvalue2").val()
});

    ....

    data: {
           'items':  JSON.stringify(items) 
          },
    ....

With the following deserialization code –

var js = new JavaScriptSerializer();
var myobj = js.Deserialize<JsonModel>(items);

To the following object –

public class JsonModel
{
    public string Item1 { get; set; }
    public string Item2 { get; set; }
}

here is the json string that is returned to my controller

[{\"Item1\":\"1|2|3|5\",\"Item2\":\"1\"}]

This is not working. When I run this code, I end up with an empty object.
However, if I do a replace on the json string and remove the [ and ], it deserialized with the correct data.

Am I handling this incorrectly – I would like to deserialize to my object without having to modify the json string.

Any thoughts would be great. Thanks.

  • 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-12T15:58:44+00:00Added an answer on June 12, 2026 at 3:58 pm

    JSON.stringify(items) is going to serialize to an array, because items is an array. What you probably want is to go:

    var jsonModel = {
      "Item1":$("myvalue").val(),      
      "Item2":$("myvalue2").val()      
    };
    
    ....
    
    {
        'items': JSON.stringify(jsonModel)
    }
    

    All I’ve really done here not used the items array.

    The only caveat is if you do in fact want to send an array of these objects back to your controller. If that is the case your deserialization code will need to look something like

    js.Deserialize<IEnumerable<JsonModel>>(items);
    

    and of course you will need to send an a serialized array back as you were doing before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I have the following jQuery: // get position on new/removed items function get_new_position_for_all_items() {
I have the following jQuery Code: $(#menu span).click(function() { var url = this.getAttribute(data-url); var
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml
I have the following jQuery code: var isUsernameAvailable = false; function CheckUsername(uname) { $.ajax({
I have the following jQuery code: $.ajax({ type: POST, url: /search, data: $(form).serialize(), success:
I have the following jQuery code: var shown = $('div.slideshow').find('div.slide:visible'); var next = shown.next();
I have the following jQuery function: function deleteHype(){ FB.api('/me/launchhype:hype', function(response) { $.each(response.data, function(i, obj){
I have the following JQuery AJAX call that sends HTML form data to my
i have this following jquery to load partial view in a div var acc

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.