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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:50:10+00:00 2026-06-01T10:50:10+00:00

How to get array data from json in c#? Here is the ajax code

  • 0

How to get array data from json in c#?

Here is the ajax code

        $.ajax({
            type: "GET",
            url: "/Weather/GetWeather",
            data: { "a": ["1,","2&"], "b" : 4 },
            success: onScc,
            error: onErr,
            dataType: "json"
        });

The ajax above will invoke method named GetWeather in Asp.net MVC.

    public string GetWeather()
    {
        //Request.QueryString.ToString()  --->  a%5b%5d=1%2c&a%5b%5d=2%26&b=4
        string a = HttpUtility.UrlDecode(Request.QueryString.ToString());
        // string a ---> a=1,&a=2&&b=4
        .....
    }

what I got from .net is —–> a[]=1,&a[]=2&&b=4

what I want to get is like —-> string[]a = ["1", "2&"] and int b = 4. BTW, I don’t want to define an object that includes a and b since these parameters are dynamic.

  • 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-01T10:50:12+00:00Added an answer on June 1, 2026 at 10:50 am

    you can use dynamic

     dynamic lst = new JavaScriptSerializer().Deserialize<dynamic>
                   (@"{ ""a"": [""1"",""2""], ""b"" : 4}");
    

    reference System.Web.Extensions

    enter image description here

    enter image description here

    edit

    after looking , you are not sending JSON to .net !!!

    var myObject = { "a": ["1,","2&"], "b" : 4 };
    
    console.log(JSON.stringify(myObject));
    

    ===> '{"a":["1,","2&"],"b":4}'
    you should send the STRING value rather then the OBJECT which you did !

    now youll have :

    enter image description here

    change :

      data: { "a": ["1,","2&"], "b" : 4 },
    
    to
    
      data:{"myValue" : JSON.stringify({ "a": ["1,","2&"], "b" : 4 })},
    

    and in c# read : myValue

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

Sidebar

Related Questions

Data sent from client will not get deserialized. Client: $.ajax({ type: 'POST', dataType: json,
How can I get the array data from a JSON sent back by my
My code: $.get('ajax/time_menus.php', { shift: $('#shifts').val() }, function(data) { //load the array into a
I aam trying to GET an array from a JSON file using JQuery's ajax
I get an variable via ajax from php file This is data for google
i've got a simple ajax call: function message(){ $.ajax({ type: GET, url: /file/timestamp=+ timestamp,
I need (recently) to get an array from the server after an ajax call
I'm using Dojo toolkit to get data from an external JSON source (a web
I'm saving my data with Array, look: Get data: $data['address'] = $this->input->post('address'); Save: $this->load->model('mymodel');
$.getJSON(./data/revenue-item-data.php,{val:'val'},function(data){ $('#totalUnits').val(data[0].SUM(item_qty)); $('#totalAmounts').val(data[0].SUM(DISTINCT net_total)); }); Here is array I get for above code: [{SUM(item_qty):68,SUM(DISTINCT

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.