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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:40:05+00:00 2026-05-26T11:40:05+00:00

I want to be able to convert a JSON object that is passed through

  • 0

I want to be able to convert a JSON object that is passed through ajax(jquery) in my webservice. At the moment I can get it to return the message “Hello World” but I don’t know how to access the passed JSON data and then convert to a collection of type IList so I can iterate over the collection. I’ve had a look around on stackoverflow but I’m getting confused what to do can some one help me.

Here is my code:

jQuery:

var data = { dvals: [{'Name' : 'Acer', 'Count' : '2'}, {'Name' : 'HP', 'Count' : '4'} ] };

function getProducts(json, pageIndex, pageSize) {
    json["PageIndex"] = pageIndex;
    json["PageSize"] = pageSize;

    $.ajax({
        type: 'POST',
        url: '/website2/WebServices/GetProducts.asmx/GetProductsAndFilters',
        data: JSON.stringify(json),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (responseText) {
            //alert(responseText.d);
            $('.console').html(responseText.d);
        },
        error: function (xhr, status, error) {
            //var msg = JSON.parse(xhr.responseText);
            //alert(msg.Message);
            $('.console').html(xhr.responseText)
        }
    });
}
getProducts(data, '0', '2');

My asp.net C#:

public class Filter
{
    public string Name;
    public int Count;
}
public class Product
{
    public int Id;
    public string Title;
    public string ShortDescription;
    public string Brand;
    public string Model;
    public double SellPrice;
    public string DescountPercentage;
    public int Votes;
    public int TotalRating;
    public double Rating
    {
        get
        {
            return Votes / TotalRating;
        }
    }
}

public class FiltersAndProducts
{
    List<Filter> Filters;
    List<Product> Products;
    int PageIndex;
    int PageSize;
}

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetProductsAndFilters()
{        
    return "Hello World";
}
  • 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-26T11:40:05+00:00Added an answer on May 26, 2026 at 11:40 am

    if you make a class like

    public class dvals{
    
    public string Name{get;set;}
    public string Count{get;set;}
    
    }
    

    prepare json

    var dvals =[{Name:'Acer',Count:'2'},{Name:'HP',Count:'4'}];
    dval=JSON.stringify(dvals);
    

    send via ajax

    $.ajax({
            type: 'POST',
            url: '/website2/WebServices/GetProducts.asmx/GetProductsAndFilters',
            data: dval,
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (responseText) {
                //alert(responseText.d);
                  console.log(responseText);
                $('.console').html(responseText.d);
            },
            error: function (xhr, status, error) {
                //var msg = JSON.parse(xhr.responseText);
                //alert(msg.Message);
                $('.console').html(xhr.responseText)
            }
        });
    

    webservice side

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string GetProductsAndFilters(IList<dvals> dvalsList)
    {        
        return "Hello World";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want an jquery inline editor that can be placed at more than one
I want to get a list of result sets and columns that i can
I want to be able to convert a List<T> into a specific JSON table-like
I want to be able to convert between the Gregorian and Julian calendars (note:
I want to be able to capture the exception that is thrown when a
I want to be able to convert a std::stack<> to a std::deque<>. Is there
I have a list of integers and I want to be able to convert
I want to convert the following json and put the values into a data
Using Python 2.6 I want to be able to convert numbers such as 00000,
I want to be able to implicitly convert Tuples of numbers (Ints and double)

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.