ln.json/json.test/Program.cs

40 lines
761 B
C#

using System;
using System.IO;
using sharp.json;
using sharp.parser;
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;
JSONParser jsonparser = new JSONParser();
Console.WriteLine("JSON test Patterns:");
Console.WriteLine();
foreach (string src in sources){
json = jsonparser.Parse(src);
Console.WriteLine("NEW PARSER: {0}",json.ToString());
}
json = jsonparser.Parse(File.ReadAllText("test.json"));
Console.WriteLine("");
Console.WriteLine("test.json file:");
Console.WriteLine("PARSED: {0}",json.ToString());
}
}
}