Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented May 4, 2025

Files

The API now integrates seamlessly with io.Files:

use text\json\{Json, FileInput, FileOutput};
use io\File;

$file= new File('file.json');

$data= Json::read(new FileInput($file));
Json::write($data, new FileOutput($file));

// It's now also possible to pass file instances directly to read()
// and to write(), which uses Format::$DEFAULT
$data= Json::read($file);
Json::write($data, $file);

Streams

The API now integrates seamlessly with I/O streams:

use text\json\{Json, StreamInput, StreamOutput};
use io\streams\{MemoryInputStream, MemoryOutputStream};

$in= new MemoryInputStream('{"test":true}');
$out= new MemoryOutputStream();

$data= Json::read(new StreamInput($in));
Json::write($data, new StreamOutput($out));

// It's now also possible to pass input strams directly to read()
// and output streams to write(), which uses Format::$DEFAULT
$data= Json::read($in);
Json::write($data, $out);

@thekid thekid merged commit c79c4a4 into master May 4, 2025
14 checks passed
@thekid thekid deleted the feature/json_io branch May 4, 2025 11:04
thekid added a commit that referenced this pull request May 4, 2025
@thekid
Copy link
Member Author

thekid commented May 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants