ln.json/json.test/Program.cs

40 lines
761 B
C#
Raw Normal View History

2017-10-26 16:41:14 +02:00
using System;
using System.IO;
using sharp.json;
2017-11-03 13:13:09 +01:00
using sharp.parser;
2017-10-26 16:41:14 +02:00
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;
2017-11-03 13:13:09 +01:00
JSONParser jsonparser = new JSONParser();
2017-10-26 16:41:14 +02:00
Console.WriteLine("JSON test Patterns:");
Console.WriteLine();
foreach (string src in sources){
2017-11-03 13:13:09 +01:00
json = jsonparser.Parse(src);
Console.WriteLine("NEW PARSER: {0}",json.ToString());
2017-10-26 16:41:14 +02:00
}
2017-11-03 13:13:09 +01:00
json = jsonparser.Parse(File.ReadAllText("test.json"));
2017-10-26 16:41:14 +02:00
Console.WriteLine("");
Console.WriteLine("test.json file:");
Console.WriteLine("PARSED: {0}",json.ToString());
}
}
}