Convert object to JSON

Posted on 2014-08-07
Last Modified: 2014-08-07
Is there an easy way to convert an object to JSON in  Something like object.ToJSON?
Public Class MyURL
    Public Property URL As String
    Public Property Description As String
    Public Property DateAdded As String
End Class
Protected Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
        Dim p As New MyURL
        Dim s As New List(Of MyURL)

        p.URL = ""
        p.Description = "Test Item 1"
        p.DateAdded = "1/1/2013"


        p.URL = ""
        p.Description = "Test Item 2"
        p.DateAdded = "12/15/2012"


        'Is there a simple toJSON function that can be used?
End Sub

Open in new window

Question by:robnhood00
    LVL 69

    Accepted Solution

    LVL 22

    Expert Comment

    Or you can just use the built in JavascriptSerializer in .net

    Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()
    Dim jsonString = serializer.Serialize(s)

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now