# See the License for the specific language governing permissions and
# limitations under the License.
-# Dynamic interface to read Json strings.
+# Dynamic interface to read JSON strings.
#
# `String::to_json_value` returns a `JsonValue` which can be queried
-# to get the underlying Json data. It can also be used as any Json types.
+# to get the underlying JSON data.
module dynamic
import error
private import static
+# Wraps a JSON value.
+#
+# Offer methods to query the type, to dynamicaly cast the underlying value and
+# to query elements (in case of a JSON object or a JSON array).
+#
+# Use `String::to_json_value` to get a `JsonValue` from a string.
class JsonValue
+
+ # The wrapped JSON value.
var value: nullable Object
# Is this value null?
# Redef parser
redef class Nvalue
+ # The represented value.
private fun to_nit_object: nullable Jsonable is abstract
end
end
redef class Nstring
+ # The represented string.
private fun to_nit_string: String do
var res = new FlatBuffer
var i = 1
end
redef class Nmembers
+ # All the key-value pairs.
private fun pairs: Array[Npair] is abstract
end
end
redef class Npair
+ # The represented key.
private fun name: String do return n_string.to_nit_string
+
+ # The represented value.
private fun value: nullable Jsonable do return n_value.to_nit_object
end
end
redef class Nelements
+ # All the items.
private fun items: Array[Nvalue] is abstract
end