41 lines
806 B
C#
41 lines
806 B
C#
|
using System;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
using sharp.json;
|
|||
|
|
|||
|
namespace json.test
|
|||
|
{
|
|||
|
class MainClass
|
|||
|
{
|
|||
|
static string[] sources = {
|
|||
|
"\"I am a string\"",
|
|||
|
"{ \"me\" : \"is a string too\"}",
|
|||
|
"[ \"this\", \"is\", \"an\", \"array\" ]"
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
public static void Main(string[] args)
|
|||
|
{
|
|||
|
JSON json;
|
|||
|
|
|||
|
Console.WriteLine("JSON test Patterns:");
|
|||
|
Console.WriteLine();
|
|||
|
|
|||
|
foreach (string src in sources){
|
|||
|
json = JSON.parse(src);
|
|||
|
|
|||
|
Console.WriteLine("SOURCE: {0}",src);
|
|||
|
Console.WriteLine("PARSED: {0}",json.ToString());
|
|||
|
Console.WriteLine("REPARSED: {0}",JSON.parse(json.ToString()).ToString());
|
|||
|
}
|
|||
|
|
|||
|
json = JSON.parse(File.ReadAllText("test.json"));
|
|||
|
Console.WriteLine("");
|
|||
|
Console.WriteLine("test.json file:");
|
|||
|
Console.WriteLine("PARSED: {0}",json.ToString());
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|