views:

134

answers:

1

Hello Everyone,

I'm sure this has been asked before but I'm not finding quite the information I'm needing so I thought I'd post this.

I've written a PHP script that returns a simple JSON object that looks like this:

{"status":"success","level":"admin"}

I'm doing a standard web request that submits the required data to the script over the internet and that's working fine.

Now, I want to use JSON.NET to pull out the individual variables so I can know what the values of "status" and "level" are. The problem is, I have no idea where to start.

I'm doing this in VB.NET (on the .NET Compact Framework). Can anyone help me? I've spent the last 2 hours on Google and can come up with nothing!

Thanks!

A: 

i think below code snippet will be useful.

Pasting the content from here http://msdn.microsoft.com/en-us/library/bb299886.aspx#intro_to_json_topic5

string jsonText = @"[""Europe"", ""Asia"", ""Australia"", ""Antarctica"",
 ""North America"", ""South America"", ""Africa""]";

using (JsonTextReader reader = new JsonTextReader(new StringReader(jsonText)))
{
    while (reader.Read())
    {
        if (reader.TokenClass == JsonTokenClass.String &&
            reader.Text.StartsWith("A"))
        {
            Console.WriteLine(reader.Text);
        }
    }
}
coder
Hi Coder,Thanks for the code snippet. After looking at the site, I see it uses either JayRock or something built into the .NET framework. The problem is that this API (either JayRock or a built in .NET class) isn't available on the Compact Framework.That's what's giving me such a freaking headache here. If I were doing it on the desktop, it would be pretty simple as you noted but on the mobile, it's a bear!Thanks anyway though!
CajunTechie
then do one thing. convert your JSON to XML or some other format for which library is available in .NET for mobile. you should be able to use it easily. hope it helps
coder