2017-11-03 13:13:09 +01:00
|
|
|
using System;
|
2017-10-26 16:41:14 +02:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-11-03 13:13:09 +01:00
|
|
|
public override string[] prettyPrint()
|
2017-10-26 16:41:14 +02:00
|
|
|
{
|
2017-11-03 13:13:09 +01:00
|
|
|
return new string[] { ToString() };
|
2017-10-26 16:41:14 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 13:13:09 +01:00
|
|
|
public override string ToString()
|
2017-10-26 16:41:14 +02:00
|
|
|
{
|
|
|
|
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....");
|
|
|
|
}
|
|
|
|
|
2017-11-03 13:13:09 +01:00
|
|
|
public override bool Boolean
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return this == True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string String
|
2017-10-26 16:41:14 +02:00
|
|
|
{
|
2017-11-03 13:13:09 +01:00
|
|
|
get
|
|
|
|
{
|
|
|
|
if (this == Null){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return base.String;
|
|
|
|
}
|
2017-10-26 16:41:14 +02:00
|
|
|
}
|
2017-11-03 13:13:09 +01:00
|
|
|
|
2017-10-26 16:41:14 +02:00
|
|
|
}
|
|
|
|
}
|