- buffer.append "\]"
- end
-
- private fun append_json_entry(iterator: Iterator[nullable Jsonable],
- buffer: Buffer) do
- buffer.append_json_of(iterator.item)
- iterator.next
- end
-end
-
-# A JSON array.
-class JsonArray
- super JsonSequenceRead[nullable Jsonable]
- super Array[nullable Jsonable]
-end
-
-redef class JsonParseError
- super Jsonable
-
- # Get the JSON representation of `self`.
- #
- # ~~~
- # var err = new JsonParseError("foo", new Position(1, 2, 3, 4, 5, 6))
- # assert err.to_json == "\{\"error\":\"JsonParseError\"," +
- # "\"position\":\{" +
- # "\"pos_start\":1,\"pos_end\":2," +
- # "\"line_start\":3,\"line_end\":4," +
- # "\"col_start\":5,\"col_end\":6" +
- # "\},\"message\":\"foo\"\}"
- # ~~~
- redef fun to_json do
- return "\{\"error\":\"JsonParseError\"," +
- "\"position\":{position.to_json}," +
- "\"message\":{message.to_json}\}"