summaryrefslogtreecommitdiff
path: root/AK/JsonValue.h
AgeCommit message (Collapse)Author
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-17AK: Add 64 bit methods to JsonValueJean-Baptiste Boric
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2020-12-30AK+Format: Remove TypeErasedFormatParams& from format function.asynts
2020-10-13Use new format functions in remaining DevTools. (#3755)Paul Scharnofske
* AK: Add formatter for JsonValue. * Inspector: Use new format functions. * Profiler: Use new format functions. * UserspaceEmulator: Use new format functions.
2020-06-13AK: JsonParser improvementsMatthew Olsson
- Parsing invalid JSON no longer asserts Instead of asserting when coming across malformed JSON, JsonParser::parse now returns an Optional<JsonValue>. - Disallow trailing commas in JSON objects and arrays - No longer parse 'undefined', as that is a purely JS thing - No longer allow non-whitespace after anything consumed by the initial parse() call. Examples of things that were valid and no longer are: - undefineddfz - {"foo": 1}abcd - [1,2,3]4 - JsonObject.for_each_member now iterates in original insertion order
2020-05-22AK: Make JsonValue and JsonObjectSerializer speak int/long/long longAndreas Kling
While width-oriented integer types are nicer from the programmer's perspective, we have to accept that C++ thinks in int/long/long long.
2020-05-16Kernel: Absorb LibBareMetal back into the kernelAndreas Kling
This was supposed to be the foundation for some kind of pre-kernel environment, but nobody is working on it right now, so let's move everything back into the kernel and remove all the confusion.
2020-04-01AK: Add equals method to JsonValue to semantically compare two values.Emanuel Sprung
This patchsets adds the semantic check of two values. One first approach was to compare the (generated) json strings of the two values. This works out in the most cases, but not with numbers, where "1.0" and "1" in JSON format are semantically the same. Therefore, this patch adds deep (recursive) check of two JsonValues.
2020-02-14AK: Add a forward declaration headerAndreas Kling
You can now #include <AK/Forward.h> to get most of the AK types as forward declarations. Header dependency explosion is one of the main contributors to compile times at the moment, so this is a step towards smaller include graphs.
2020-02-09AK: Apply changes for the Bootstrapper environmentLiav A
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-12JsonValue: Fix wrong return type of as_u32() and friendsAndreas Kling
2019-10-29AK: Allow JsonValue to store 64-bit integers internallyAndreas Kling
Add dedicated internal types for Int64 and UnsignedInt64. This makes it a bit more straightforward to work with 64-bit numbers (instead of just implicitly storing them as doubles.)
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-07JsonValue: Add as_string_or(String)Andreas Kling
Return the contained string if the value *is* a string, otherwise it returns the alternative string passed in the parameter.
2019-08-07JSON: Templatize the JSON serialization codeAndreas Kling
This makes it possible to use something other than a StringBuilder for serialization (and to produce something other than a String.) :^)
2019-08-04JsonObject: Add move constructors for JsonObject(Json{Array,Object}&&)Andreas Kling
This also helps avoid JsonValue copying during parse.
2019-07-18JsonValue: Add to_uint(), to_int() and as_double().Andreas Kling
The to_foo() functions are for converting when you might not be sure of the underlying value type. The as_foo() family assumes that you know exactly what the underlying value type is.
2019-07-08AK: Add JsonValue::to_bool().Andreas Kling
2019-07-08AK: Make it easy to convert between JsonValue and IPv4Address.Andreas Kling
They still use string storage, but this change makes it nice and easy to work with IPv4 addresses in JSON data.
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-29JsonValue: Add is_bool() and various as_foo() helpers.Andreas Kling
2019-06-29Kernel: Change the format of /proc/all to JSON.Andreas Kling
Update ProcessManager, top and WSCPUMonitor to handle the new format. Since the kernel is not allowed to use floating-point math, we now compile the JSON classes in AK without JsonValue::Type::Double support. To accomodate large unsigned ints, I added a JsonValue::Type::UnsignedInt.
2019-06-24AK: Add JsonValue::to_string(default_value = {}).Andreas Kling
2019-06-24JsonValue: Add as_array() and as_object().Andreas Kling
2019-06-24AK: Implement a naive JSON parser.Andreas Kling
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-19AK: Add some convenient functions to JsonValue.Andreas Kling
2019-06-18AK: Rename JsonObject::to_string() and pals to serialized().Andreas Kling
And the variant that serializes into a StringBuilder is called serialize().
2019-06-18AK: Add JsonValue(const char*).Andreas Kling
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-18AK: Add JsonValue(unsigned) ctor and as_string().Andreas Kling
2019-06-17AK: Use a single StringBuilder throughout JSON serialization.Andreas Kling
2019-06-17AK: Add some classes for JSON encoding.Andreas Kling
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.