summaryrefslogtreecommitdiff
path: root/AK/JsonParser.cpp
AgeCommit message (Collapse)Author
2021-02-26Everywhere: Remove a bunch of redundant 'AK::' namespace prefixesLinus Groh
This is basically just for consistency, it's quite strange to see multiple AK container types next to each other, some with and some without the namespace prefix - we're 'using AK::Foo;' a lot and should leverage that. :^)
2021-02-08Everywhere: Remove unnecessary headers 4/4Ben Wiederhake
Arbitrarily split up to make git bisect easier. These unnecessary #include's were found by combining an automated tool (which determined likely candidates) and some brain power (which decided whether the #include is also semantically superfluous).
2020-12-21AK: Make JsonParser::parse_number properly parse >32bit intsSahan Fernando
2020-10-06AK: check fractional string has_value() in JsonParserTucker Polomik
Resolves #3670
2020-09-27AK: Remove the ctype adapters and use the actual ctype functions insteadBenoît Lormeau
This finally takes care of the kind-of excessive boilerplate code that were the ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel (for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there wasn't any string stuff used in ctype. Instead of all this I could have put static derivatives of `is_any_of()` in the concerned AK files, however that would have meant more boilerplate and workarounds; so I went for the Kernel approach.
2020-08-09AK: Add a GenericLexer and extend the JsonParser with it (#2696)Benoît Lormeau
2020-08-05Unicode: Try s/codepoint/code_point/g againNico Weber
This time, without trailing 's'. Ran: git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
2020-08-05Revert "Unicode: s/codepoint/code_point/g"Nico Weber
This reverts commit ea9ac3155d1774f13ac4e9a96605c0e85a8f299e. It replaced "codepoint" with "code_points", not "code_point".
2020-08-03Unicode: s/codepoint/code_point/gAndreas Kling
Unicode calls them "code points" so let's follow their style.
2020-06-20AK: Fix JsonParser double encoding multibyte utf-8 chararctersLepkoQQ
2020-06-16AK: JsonParser, replace char type to u32 for code pointHüseyin ASLITÜRK
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-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-06-03AK: JSON, Escape spacial character in string serializationHüseyin ASLITÜRK
2020-04-04AK: Break on end of input in JsonParser::consume_quoted_stringTibor Nagy
Fixes #1599
2020-03-31AK: A few JSON improvementsEmanuel Sprung
* Add double number to object serializer * Handle negative double numbers correctly * Handle \r and \n in quoted strings independently This improves the situation when keys contain \r or \n that currently has the effect that "a\rkey" and "a\nkey" in an JSON object are the same key value.
2020-03-24AK: Fix JsonParser kernel build (no floats/doubles in kernel code)Andreas Kling
2020-03-24AK: Add parsing of JSON double valuesEmanuel Sprung
This patch adds the parsing of double values to the JSON parser. There is another char buffer that get's filled when a "." is present in the number parsing. When number finished, a divider is calculated to transform the number behind the "." to the actual fraction value.
2020-03-08AK: Move memory stuff (fast memcpy, etc) to a separate headerAndreas Kling
Move the "fast memcpy" stuff out of StdLibExtras.h and into Memory.h. This will break a ton of things that were relying on StdLibExtras.h to include a bunch of other headers. Fix will follow immediately after. This makes it possible to include StdLibExtras.h from Types.h, which is the main point of this exercise.
2020-03-01AK: Remove unnecessary casts to size_t, after Vector changesAndreas Kling
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
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-29AK: Fix JSON parser crashing when encountering UTF-8Andreas Kling
The mechanism that caches the most recently seen string for each first character was indexing into the cache using a 'char' subscript. Oops!
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-08-14JsonParser: "" is an empty string, not a null valueAndreas Kling
2019-08-07JsonParser: Scan ahead to find the first special char in quoted stringsAndreas Kling
This allows us to take advantage of the now-optimized (to do memmove()) Vector::append(const T*, int count) for collecting these strings. This is a ~15% speedup on the load_4chan_catalog benchmark.
2019-08-04JsonParser: Fold extract_while() into parse_number()Andreas Kling
It wasn't unsed anywhere else anyway, and this is actually ~1% faster on the load_4chan_catalog benchmark.
2019-08-04JsonParser: Oops, fix build.Andreas Kling
2019-08-04JsonParser: Cache the last seen string starting with each possible charAndreas Kling
Keep a 256-entry string cache during parse to avoid creating some new strings when possible. This cache is far from perfect but very cheap. Since none of the strings are transient, this only costs us a couple of pointers and a bit of ref-count manipulation. The cache hit rate on 4chan_catalog.json is ~33% and the speedup on the load_4chan_catalog benchmark is ~7%.
2019-08-04JsonParser: Some minor optimizationsAndreas Kling
- Return more specific types from parse_array() and parse_object(). - Don't create a throwaway String in extract_while(). - Use a StringView in parse_number() to avoid a throwaway String.
2019-08-04JsonParser: Use Vector<char, 1024> instead of StringBuilder in parsingAndreas Kling
This is a 10-12% speedup on the 4chan thread catalog JSON.
2019-08-04JsonParser: When encountering \uXXXX, just emit a "?" for now.Andreas Kling
2019-08-01JsonParser: Merge the parsing of '\n' and '\r' in quoted stringsAndreas Kling
2019-07-08AK: Add JsonObject::set(key, &&value) overload.Andreas Kling
This dodges a whole bunch of value copying in JsonParser.
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-25JsonParser: Support basic escaped string characters.Andreas Kling
I didn't implement \uXXXX-style escape in this patch. That's a FIXME.
2019-06-24AK: Let's put the JSON parsing in a separate class.Andreas Kling