@@ -41,6 +41,21 @@ class JSONValue extends @json_value, Locatable {
4141 )
4242 }
4343
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+
4459 override string getAPrimaryQlClass ( ) { result = "JSONValue" }
4560}
4661
@@ -129,13 +144,10 @@ class JSONString extends @json_string, JSONPrimitiveValue {
129144 * ```
130145 */
131146class 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" }
134148
135149 /** 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 ( ) }
139151}
140152
141153/**
@@ -148,13 +160,10 @@ class JSONArray extends @json_array, JSONValue {
148160 * ```
149161 */
150162class 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" }
153164
154165 /** 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 ( ) }
158167}
159168
160169/**
0 commit comments