I have this code:
["ok", "Google", "google"]
That I get from decenturl.com/api-title?u=google.com
. This API gets the title of a site, but it is "encoded" in the format above. What is the format of this? I tried to search for it, but without the name I can't do anything. It looks like JSON, but it isn't, I guess.
Anyway, how do I parse this in C#? Will be better if this work in framework 2.0, but if can't, I accept above frameworks. There is a built-in method for that? Or I need to do it manually?
Thanks.
It is JSON, just for an array. Assuming the URL always gives you back JSON, you could parse it like this (using Json.NET, which still supports .NET 2.0):
using System;
using Newtonsoft.Json.Linq;
class Test
{
static void Main()
{
string json = "[\"ok\", \"Google\", \"google\"]";
var array = JArray.Parse(json);
Console.WriteLine(array[0]); // For example
}
}
See more on this question at Stackoverflow