Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs JsonParser.Token

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module 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;
}

Documentation

A token generated by JsonParser.next- ALL character slices are from the original input.

Enums

Name Description
Type

What this token represents.

Functions

Name Description
asBool

Retrieves the value of this boolean token.

asEscapedString

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.

asInt

Retrieves the value of this integer token, and attempts to coerce it into the given IntegralT.

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 asInt, but will fail an assert if conversion wasn't possible.

Variables

Name Description
rawText

The whole raw text of this token, e.g. for strings this includes the start and end quotes.

type