12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455module juptune.data.json.parser;
static struct Token
{
/++ FUNCTIONS ++/
/// Retrieves the value of this boolean token.
bool asBool();
/// Provides an InputRange of const(char)[] which will provide the string value of this string/name token, but with any escape characters transformed into their underlying value.
auto asEscapedString();
/// Retrieves the value of this integer token, and attempts to coerce it into the given IntegralT .
Result asInt(IntegralT)(IntegralT number);
/// Retrieves the string value of this string/name token (without the start and end quotes).
const char[] asUnescapedString();
/// Whether this string/name token has escape characters within it. This can be used to avoid needless allocations in certain use cases (rather than always trying to escape the string).
bool hasEscapeChars();
/// Similar to asInt , but will fail an assert if conversion wasn't possible.
IntegralT mustAsInt(IntegralT)();
/++ ENUMS ++/
/// What this token represents.
enum Type : int
{
///
FAILSAFE = 0,
/// "{"
objectStart = 1,
/// "}"
objectEnd = 2,
/// "["
arrayStart = 3,
/// "]"
arrayEnd = 4,
/// Given {"name": "value", "foo": "bar"} , this token is for "name" and "foo"
name = 5,
/// true or false
boolean = 6,
/// null
null_ = 7,
/// 123 or -123
integer = 8,
/// [-]1.2, [-]1.2e3, [-]1.2e+3, [-]1.2e-3
floating = 9,
/// "value"
string = 10
}
/++ VARIABLES ++/
/// The whole raw text of this token, e.g. for strings this includes the start and end quotes.
const char[] rawText;
///
JsonParser.Token.Type type;
}
A token generated by JsonParser.next- ALL character slices are from the original input.
| Name | Description |
|---|---|
| Type |
What this token represents. |
| Name | Description |
|---|---|
| asBool |
Retrieves the value of this boolean token. |
| asEscapedString |
Provides an InputRange of |
| asInt |
Retrieves the value of this integer token, and attempts to coerce it into the given |
| asUnescapedString |
Retrieves the string value of this string/name token (without the start and end quotes). |
| hasEscapeChars |
Whether this string/name token has escape characters within it. This can be used to avoid needless allocations in certain use cases (rather than always trying to escape the string). |
| mustAsInt |
Similar to |
| Name | Description |
|---|---|
| rawText |
The whole raw text of this token, e.g. for strings this includes the start and end quotes. |
| type |