EDIT
For absolute clarity, JSON Array means the form [91,...,44,...,93], where no JSON Object {} is expected; just flat Array format.
An array is an ordered collection of values. An array begins with [left bracket and ends with ]right bracket. Values are separated by ,comma.

Kindly keep in mind that "whitespace" is/can be counted as bytes; see Eliminate space counted as message length and Eliminate space counted as message length.
I'm working on implementing 64 MiB input support for the Native Messaging hosts I've written, and gotten a bunch of help writing.
So far I've completed JavaScript that works using node, deno, and bun; Bytecode Alliance's javy which depends on QuickJS (Rust crate) to compile JavaScript source to WASM; and AssemblyScript (see Parsing JSON manually - #11 by guest271314).
This is the protocol Native messaging | Chrome for Developers
Chrome starts each native messaging host in a separate process and communicates with it using standard input (
stdin) and standard output (stdout). The same format is used to send messages in both directions; each message is serialized using JSON, UTF-8 encoded and is preceded with 32-bit message length in native byte order. The maximum size of a single message from the native messaging host is 1 MB, mainly to protect Chrome from misbehaving native applications. The maximum size of the message sent to the native messaging host is 64 MiB.
What I'm working wiith right now NativeMessagingHosts/nm_rust.rs at main · guest271314/NativeMessagingHosts · GitHub.
I am not a Rustacean; I don't write Rust everyday. I think getMessage() doesn't have to change; only sendMessage() needs to be modified to parse, extract, and send valid JSON (encoded as u8 in the working code I've got) back to the browser
pub fn sendMessage(message: &[u8]) -> io::Result<()> {
let mut stdout = io::stdout();
let length = message.len() as u32;
stdout.write_all(&length.to_ne_bytes())?;
stdout.write_all(message)?;
stdout.flush()?;
Ok(())
}
How would you go about doing that?
Related: How to implement a Native Messaging host using only Rust standard library?