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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:49:53+00:00 2026-05-23T12:49:53+00:00

How to serialise an object to json and send it to a web service?

  • 0

How to serialise an object to json and send it to a web service?

var object = something....
function BindJson() {
        $.ajax({
            type: "POST",
            url: "NewPage.aspx/GetJson",
            data: "{}",
            contentType: "application/json",
            dataType: "json",
            success: function (data) {

            }
        })
    }

<body onload="BindJson();">

Server:

[WebMethod]
        public static string GetSerializedJsonObject()
        {
            return "";
        }
  • 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-23T12:49:53+00:00Added an answer on May 23, 2026 at 12:49 pm

    This will work for you (full working code sample below). The key is to pass in a Person object. Also, I used a simple web service (myService.asmx) instead of an aspx page. Why bother with the extra overhead if it isn’t needed?

    The key is, on the client, create a Person object and then use JSON.stringify to pass the Person object to the webservice.

    Javascript

    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js"></script>
    <script type="text/javascript">
        function BindJson() {
            $.ajax({
                type: "POST",
                url: "myService.asmx/SerializeJson",
                data: JSON.stringify({ person:{ firstName: "Denny", lastName: "Cherian", department: "Microsoft PSS", address: { addressline1: "Microsoft India GTSC", addressline2: "PSS - DSI", city: "Bangalore", state: "Karnataka", country: "India", pin: "560028" }, technologies: ["IIS", "ASP.NET", "JavaScript", "AJAX"] }}),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data1) {
                    alert(data1.d);
                },
                error: function (request, status, errorThrown) {
                    alert(status);
                }
            });
        }
    
        $(document).ready(function() {
            BindJson();    
        });
    </script>
    

    C#

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace TestProject
    {
        /// <summary>
        /// Summary description for myService
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        [System.Web.Script.Services.ScriptService]
        public class myService : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string SerializeJson(Person person)
            {
                return "Success";
            }
    
            public class Person
            {
                public string firstName { get; set; }
                public string lastName { get; set; }
                public string department { get; set; }
                public Address address { get; set; }
                public string[] technologies { get; set; }
            }
    
            public class Address
            {
                public string addressline1 { get; set; }
                public string addressline2 { get; set; }
                public string city { get; set; }
                public string state { get; set; }
                public string country { get; set; }
                public string pin { get; set; }            
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I access a web service in a POST method. I need to send to
I'm making a call to another ajax page, the call posts a json object.
How do you return a serialized JSON object to the client side using ASP.NET
I have an object in Javascript that looks like this function MyObject(){ this.name=; this.id=0;
I'm using XStream and JETTISON's Stax JSON serializer to send/receive messages to/from JSON javascripts
I want to serialize a form into json, process the json object, then reserialize
I am using DataContractJsonSerializer to serialize an object to json, and then returning to
Currently, I'm using an AJAX Handler to populate the JSTree: $(function () { $(#jstree).jstree({
I have an object, and before I serialize it to Json, I'd like to
Alright, so I have some jQuery code that will send an AJAX request to

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.