How do I turn a C object into a JSON string in NET

0 votes

The following is my classes

class MyDate
{
    int year, month, day;
}

class Lad
{
    string firstName;
    string lastName;
    MyDate dateOfBirth;
}

And I would like to turn lad into json string to look like this

{
    "firstName":"Markoff",
    "lastName":"Chaney",
    "dateOfBirth":
    {
        "year":"1901",
        "month":"4",
        "day":"30"
    }
}

(Excluding formatting) I discovered this link, but.NET 4 doesn't support the namespace it uses. JSON.NET is another option I've heard about, but I don't like the idea of requiring external DLL files, and their website currently appears to be unavailable.

Is there any alternative choices except writing a JSON string writer by hand?

Sep 26 in C# by krishna
• 2,820 points
34 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
1 answer

How do I specify the exit code of a console application in .NET

Simply put, you can return the exit ...READ MORE

answered Jun 11 in C# by pranav
• 2,580 points
534 views
0 votes
1 answer

How to convert JSON text into objects using C#

To make a class out of a ...READ MORE

answered Jun 13 in C# by krishna
• 2,820 points
72 views
0 votes
1 answer

How to send email in ASP.NET C#

You can try this using Hotmail like ...READ MORE

answered Jun 14 in C# by krishna
• 2,820 points
91 views
0 votes
1 answer

How to find the extension of a file in C#

Go to here https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getextension?redirectedfrom=MSDN&view=net-6.0#System_IO_Path_GetExtension_System_String_ string myFilePath = @"C:\MyFile.txt"; string ext ...READ MORE

answered Jun 21 in C# by jyoti
• 1,240 points
84 views
0 votes
0 answers

How can I split a string with a string delimiter

Suppose this is my string My name is ...READ MORE

Jun 11 in C# by krishna
• 2,820 points
41 views
0 votes
0 answers

How do I determine the size of my array in C?

How do I figure out my array's ...READ MORE

Nov 16 in C# by Ashwini
• 2,760 points
21 views
0 votes
1 answer

How do I turn a C# object into a JSON string in .NET

Newtonsoft.json can be used to accomplish this. ...READ MORE

answered Jun 13 in C# by krishna
• 2,820 points
83 views
0 votes
0 answers

How do I turn a C# object into a JSON string in .NET?

I have classes like these: class MyDate { ...READ MORE

Sep 20 in Android by Edureka
• 12,390 points
46 views
0 votes
1 answer
0 votes
2 answers

Is there a .NET equivalent to Apache Hadoop?

Hadoop is a Java-based platform. So, to ...READ MORE

answered Jul 16, 2020 in Big Data Hadoop by Suhana
• 340 points
776 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP