forked from ln-dotnet/ln.json
54 lines
937 B
C#
54 lines
937 B
C#
using System;
|
|
namespace sharp.json
|
|
{
|
|
public class JSONSpecial: JSON
|
|
{
|
|
public static readonly JSON True = new JSONSpecial(JSONTypes.True);
|
|
public static readonly JSON False = new JSONSpecial(JSONTypes.False);
|
|
public static readonly JSON Null = new JSONSpecial(JSONTypes.Null);
|
|
|
|
private JSONSpecial(JSONTypes type)
|
|
:base(type)
|
|
{
|
|
}
|
|
|
|
public override string[] prettyPrint()
|
|
{
|
|
return new string[] { ToString() };
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
switch (JSONType){
|
|
case JSONTypes.Null:
|
|
return "null";
|
|
case JSONTypes.True:
|
|
return "true";
|
|
case JSONTypes.False:
|
|
return "false";
|
|
}
|
|
throw new NotImplementedException("JSON Special Type badly wrong....");
|
|
}
|
|
|
|
public override bool Boolean
|
|
{
|
|
get
|
|
{
|
|
return this == True;
|
|
}
|
|
}
|
|
|
|
public override string String
|
|
{
|
|
get
|
|
{
|
|
if (this == Null){
|
|
return null;
|
|
}
|
|
return base.String;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|