Commit graph

8 commits

Author SHA1 Message Date
Andreas Kling 8392c549a3 JsonValue: Add as_array() and as_object(). 2019-06-24 12:03:31 +02:00
Andreas Kling 009b9bfd10 AK: Implement a naive JSON parser.
This parser assumes that the JSON is well-formed and will choke horribly
on invalid input.

Since we're primarily interested in parsing our own output right now, this
is less of a problem. Longer-term we're gonna need something better. :^)
2019-06-24 11:28:24 +02:00
Andreas Kling c5d623e048 AK: Add some convenient functions to JsonValue. 2019-06-19 13:08:07 +02:00
Andreas Kling aa3df518e7 AK: Rename JsonObject::to_string() and pals to serialized().
And the variant that serializes into a StringBuilder is called serialize().
2019-06-18 09:37:47 +02:00
Andreas Kling 4147394dcb AK: Add JsonValue(const char*).
This should obviously become a string, but if we don't have it, constructing
from a string literal ends up creating a boolean value.
2019-06-18 09:11:31 +02:00
Andreas Kling 1a761ea4fd AK: Add JsonValue(unsigned) ctor and as_string(). 2019-06-18 08:55:58 +02:00
Andreas Kling ee347effac AK: Use a single StringBuilder throughout JSON serialization. 2019-06-17 21:36:54 +02:00
Andreas Kling 04a8fc9bd7 AK: Add some classes for JSON encoding.
This patch adds JsonValue, JsonObject and JsonArray. You can use them to
build up a JsonObject and then serialize it to a string via to_string().

This patch only implements encoding, no decoding yet.
2019-06-17 19:47:35 +02:00