using System; using System.Text; namespace AllocsFixes.JSON { public class JSONBoolean : JSONValue { private bool value; public JSONBoolean (bool value) { this.value = value; } public bool GetBool () { return value; } public override void ToString (StringBuilder stringBuilder, bool prettyPrint = false, int currentLevel = 0) { stringBuilder.Append (value ? "true" : "false"); } public static JSONBoolean Parse (string json, ref int offset) { //Log.Out ("ParseBool enter (" + offset + ")"); if (json.Substring (offset, 4).Equals ("true")) { //Log.Out ("JSON:Parsed Bool: true"); offset += 4; return new JSONBoolean (true); } else if (json.Substring (offset, 5).Equals ("false")) { //Log.Out ("JSON:Parsed Bool: false"); offset += 5; return new JSONBoolean (false); } else { throw new MalformedJSONException ("No valid boolean found"); } } } }