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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:20:47+00:00 2026-06-14T12:20:47+00:00

I was hoping someone could help me with a problem serialzing data into a

  • 0

I was hoping someone could help me with a problem serialzing data into a class please?

I need to send the following json string to a webservice:

{ “arrivalAt”: “2012-12-24T20:00:00.0000000Z”, “pickup”:{“streetName”:”Amaliegade”,”houseNumber”:”36″,”zipCode”:”1256″,”city”:”Copenhagen K”,”country”:”DK”,”lat”:55.68,”lng”:12.59}, “dropoff”:{“streetName”:”Amaliegade”,”houseNumber”:”36″,”zipCode”:”1256″,”city”:”Copenhagen K”,”country”:”DK”,”lat”:55.68,”lng”:12.59}, “vehicleType”: “fourSeaterAny”, “comments”: “Hello” }’

I put this json string into http://json2csharp.com/ and it generated the following class:

public class Pickup
{
public string streetName { get; set; }
public string houseNumber { get; set; }
public string zipCode { get; set; }
public string city { get; set; }
public string country { get; set; }
public double lat { get; set; }
public double lng { get; set; }
}

public class Dropoff
{
public string streetName { get; set; }
public string houseNumber { get; set; }
public string zipCode { get; set; }
public string city { get; set; }
public string country { get; set; }
public double lat { get; set; }
public double lng { get; set; }
}

public class RootObject
{
public string arrivalAt { get; set; }
public Pickup pickup { get; set; }
public Dropoff dropoff { get; set; }
public string vehicleType { get; set; }
public string comments { get; set; }
}

I have managed to do this before but have never had a situation where is there is a class within a class, so to speak. Meaning the “Pickup” & “DropOff” settings…

I am stuck when i try to work out what to do at this line…

Booking bookingdetails = new ClickATaxi_Classes.Booking(THIS IS WHERE I WILL PUT THE 17 BITS OF INFORMATION BUT HOW?);

I get the feeling there is something i need to do to the class to make it accept arguments but i have no idea where to start and how to send the pickup and dropoff information

can anyone help please?

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-14T12:20:48+00:00Added an answer on June 14, 2026 at 12:20 pm

    First you should refactor that generated code a little bit

    public class Location
    {
         public string streetName { get; set; }
         public string houseNumber { get; set; }
         public string zipCode { get; set; }
         public string city { get; set; }
         public string country { get; set; }
         public double lat { get; set; }
         public double lng { get; set; }
    }
    
    public class Booking
    {
         public string arrivalAt { get; set; }
         public Location pickup { get; set; }
         public Location dropoff { get; set; }
         public string vehicleType { get; set; }
         public string comments { get; set; }
    }
    

    There is no need for two classes that mean the same thing. After that you will just instantiate the booking object.

    Booking obj = new Booking { arrivalAt = "ARRIVAL", pickup = new Location { streetName = "", houseNumber = "" ... }, dropoff = new Location { streetName = "", houseNumber = "" ...}, vehicleType = "", comments = "" }
    

    Next you will serialize to a string, I like JSON.NET but you can use any serializer.
    If you want to use JSON.NET you can install it via Nuget by following these instructions, next add the using statement to the top of your class that will serialize the object:
    using Newtonsoft.Json;

    Finally just call JsonConvert

    string json = JsonConvert.SerializeObject(product);
    

    Here are some links to other serializers:

    • http://msdn.microsoft.com/en-us/library/bb410770.aspx
    • http://www.servicestack.net/docs/text-serializers/json-csv-jsv-serializers
    • http://code.google.com/p/protobuf-net/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was hoping someone could help me with the following script: jQuery(document).ready(function($) { $(.infoBoxBtn
We have an interesting problem that I was hoping someone could help to shed
I was hoping someone could help me out with this stupid problem I'm having
I got a problem I was hoping someone could help me figure out! I
I was hoping someone could help me out with a small problem I am
I'm hoping someone could help me with this problem. Say I have 3 DB
I've come across 2 confusing problems in SML and was hoping someone could help
I was hoping someone could help me with submitting the answers to an HTML
I was hoping someone could help me with a little issue I'm having trouble
Im starting to understand how Magento Event Observers work and hoping someone could help

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.