Last active
November 9, 2022 21:23
-
-
Save IanWold/320527877e5af2d8ebe356edd7b7e4c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JSONValue {} | |
public class JSONObject : JSONValue | |
{ | |
public Dictionary<string, JSONValue> Pairs { get; set; } | |
public JSONObject(IEnumerable<KeyValuePair<string, JSONValue>> pairs) | |
{ | |
Pairs = new Dictionary<string, JSONValue>(); | |
if (pairs != null) | |
{ | |
foreach (var p in pairs) | |
{ | |
Pairs.Add(p.Key, p.Value); | |
} | |
} | |
} | |
} | |
public class JSONArray : JSONValue | |
{ | |
public List<JSONValue> Elements { get; set; } | |
public JSONArray(IEnumerable<JSONValue> elements) | |
{ | |
Elements = new List<JSONValue>(); | |
if (elements != null) | |
{ | |
foreach (var e in elements) | |
{ | |
Elements.Add(e); | |
} | |
} | |
} | |
} | |
public class JSONLiteral : JSONValue | |
{ | |
public string Value { get; set; } | |
public LiteralType ValueType { get; set; } | |
public JSONLiteral(string value, LiteralType type) | |
{ | |
Value = value; | |
ValueType = type; | |
} | |
pubilc static enum LiteralType | |
{ | |
String, | |
Number, | |
Boolean, | |
Null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment