1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

js: Add a simple loadJSON(path) built-in to load JSON from a file

This is very handy when you want to load data from /proc, for example.
This commit is contained in:
Andreas Kling 2021-09-16 21:48:07 +02:00
parent d0506730b8
commit 63a0ebcc90
2 changed files with 36 additions and 1 deletions

View file

@ -22,6 +22,8 @@ public:
// test-js to communicate between the JS tests and the C++ test runner.
static String stringify_impl(GlobalObject&, Value value, Value replacer, Value space);
static Value parse_json_value(GlobalObject&, const JsonValue&);
private:
struct StringifyState {
FunctionObject* replacer_function { nullptr };
@ -40,7 +42,6 @@ private:
// Parse helpers
static Object* parse_json_object(GlobalObject&, const JsonObject&);
static Array* parse_json_array(GlobalObject&, const JsonArray&);
static Value parse_json_value(GlobalObject&, const JsonValue&);
static Value internalize_json_property(GlobalObject&, Object* holder, PropertyName const& name, FunctionObject& reviver);
JS_DECLARE_NATIVE_FUNCTION(stringify);