@@ -41,6 +41,21 @@ class JSONValue extends @json_value, Locatable {
41
41
)
42
42
}
43
43
44
+ /** If this is an object, gets the value of property `name`. */
45
+ JSONValue getPropValue ( string name ) { json_properties ( this , name , result ) }
46
+
47
+ /** If this is an array, gets the value of the `i`th element. */
48
+ JSONValue getElementValue ( int i ) { result = this .( JSONArray ) .getChild ( i ) }
49
+
50
+ /** If this is a string constant, gets the value of the string. */
51
+ string getStringValue ( ) { result = this .( JSONString ) .getValue ( ) }
52
+
53
+ /** If this is an integer constant, gets its numeric value. */
54
+ int getIntValue ( ) { result = this .( JSONNumber ) .getValue ( ) .toInt ( ) }
55
+
56
+ /** If this is a boolean constant, gets its boolean value. */
57
+ boolean getBooleanValue ( ) { result .toString ( ) = this .( JSONBoolean ) .getValue ( ) }
58
+
44
59
override string getAPrimaryQlClass ( ) { result = "JSONValue" }
45
60
}
46
61
@@ -129,13 +144,10 @@ class JSONString extends @json_string, JSONPrimitiveValue {
129
144
* ```
130
145
*/
131
146
class JSONArray extends @json_array, JSONValue {
132
- /** Gets the value of the `i`th element of this array. */
133
- JSONValue getElementValue ( int i ) { result = getChild ( i ) }
147
+ override string getAPrimaryQlClass ( ) { result = "JSONArray" }
134
148
135
149
/** Gets the string value of the `i`th element of this array. */
136
- string getElementStringValue ( int i ) { result = getElementValue ( i ) .( JSONString ) .getValue ( ) }
137
-
138
- override string getAPrimaryQlClass ( ) { result = "JSONArray" }
150
+ string getElementStringValue ( int i ) { result = getElementValue ( i ) .getStringValue ( ) }
139
151
}
140
152
141
153
/**
@@ -148,13 +160,10 @@ class JSONArray extends @json_array, JSONValue {
148
160
* ```
149
161
*/
150
162
class JSONObject extends @json_object, JSONValue {
151
- /** Gets the value of property `name` of this object. */
152
- JSONValue getPropValue ( string name ) { json_properties ( this , name , result ) }
163
+ override string getAPrimaryQlClass ( ) { result = "JSONObject" }
153
164
154
165
/** Gets the string value of property `name` of this object. */
155
- string getPropStringValue ( string name ) { result = getPropValue ( name ) .( JSONString ) .getValue ( ) }
156
-
157
- override string getAPrimaryQlClass ( ) { result = "JSONObject" }
166
+ string getPropStringValue ( string name ) { result = getPropValue ( name ) .getStringValue ( ) }
158
167
}
159
168
160
169
/**
0 commit comments