Discuss this help topic in SecureBlackbox Forum
Handle simple types
JSON supports values of four simple types: boolean, number, string and null. All of these value types are handled by TElJsonValue class. This class has two properties which show the current state of the entity: ValueType (TSBJsonType) and Value (string). ValueType property returns the current type of the stored value. Value property returns the string representation of the current value.
There are two ways to create a new entity for a certain type:
// creates a null entity; ValueType is jsonNull, Value is "null" var nullValue = new TElJsonValue(); // creates a boolean entity; ValueType is jsonBoolean, Value is "false" var boolValue = new TElJsonValue(false); // creates a number entity; ValueType is jsonNumber, Value is "100" var intValue = new TElJsonValue(100); // creates a number entity; ValueType is jsonNumber, Value is "236.94" var numberValue = new TElJsonValue(236.94); // creates a string entity; ValueType is jsonString, Value is "test" var stringValue = new TElJsonValue("test");
var value = new TElJsonValue(); // set a boolean value; ValueType is jsonBoolean, Value is "true" value.AsBoolean = true; // set an integer value; ValueType is jsonNumber, Value is "100" value.AsInteger = 100; // set a double value; ValueType is jsonNumber, Value is "236.94" value.AsNumber = 236.94; // set a string value; ValueType is jsonString, Value is "test" value.AsString = "test"; // set a null value; ValueType is jsonNull, Value is "null" value.IsNull = true;
To get the current type of the value stored in a TElJsonValue object, check its ValueType property. Also it's possible to use its IsBoolean, IsNull, IsNumber and IsString properties - they return True if the value is of correspondent type.
There are four properties that return the value stored in a TElJsonValue object: