mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +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/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
@ -43,15 +43,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
VERIFY(spaces_in_indent >= 0);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
RefPtr<Core::File> file;
|
||||
if (path == nullptr)
|
||||
file = Core::File::standard_input();
|
||||
else
|
||||
file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
|
||||
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));
|
||||
if (!dotted_key.is_empty()) {
|
||||
auto key_parts = dotted_key.split_view('.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue