mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
json: Port to Core::Stream
This commit is contained in:
parent
1d67a1e73f
commit
678b4983cb
1 changed files with 3 additions and 7 deletions
|
@ -14,7 +14,7 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/Stream.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -43,15 +43,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
VERIFY(spaces_in_indent >= 0);
|
VERIFY(spaces_in_indent >= 0);
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
RefPtr<Core::File> file;
|
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||||
if (path == nullptr)
|
|
||||||
file = Core::File::standard_input();
|
|
||||||
else
|
|
||||||
file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
|
|
||||||
|
|
||||||
TRY(Core::System::pledge("stdio"));
|
TRY(Core::System::pledge("stdio"));
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = TRY(file->read_all());
|
||||||
auto json = TRY(JsonValue::from_string(file_contents));
|
auto json = TRY(JsonValue::from_string(file_contents));
|
||||||
if (!dotted_key.is_empty()) {
|
if (!dotted_key.is_empty()) {
|
||||||
auto key_parts = dotted_key.split_view('.');
|
auto key_parts = dotted_key.split_view('.');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue