0

In my ASP.NET MVC project I am conecting to a remote cloud server which is returning the data in json like:

[{
    "name":"new-service-dev",
    "Isenabled":"true",
    "ttl":86400,
    "cdn_uri":"http://c0099.cdn2.files.rackspacecloud.com",
    "referrer_acl":"",
    "useragent_acl":"", 
    "log_":"false"
}]

Now I want to get all the values in list or array format, for example I want to get "cdn_uri".

I also want to create JSON somewhere in my code, how do I create and write JSON?

1
  • Do you want to parse the results in using Java Script or c#/VB.NET? Commented Oct 19, 2010 at 13:45

2 Answers 2

2

You can use the JSON.Net component from codeplex:

http://json.codeplex.com/

This will let you read/write JSON. Here's a simple example using your JSON from the question:

    static void Main(string[] args)
    {
        JObject o =
            JObject.Parse(
                "{    \"name\":\"new-service-dev\",    \"Isenabled\":\"true\",    \"ttl\":86400,    \"cdn_uri\":\"http://c0099.cdn2.files.rackspacecloud.com\",    \"referrer_acl\":\"\",    \"useragent_acl\":\"\",     \"log_\":\"false\"}");

        string cdn_uri = (string)o.SelectToken("cdn_uri");
        Console.WriteLine(cdn_uri);
        Console.ReadKey();
    }
Sign up to request clarification or add additional context in comments.

Comments

1

asp.net has an extension dll called system.web.extensions which is having support for javascript and json serialization. see this link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.