-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from Shopify/json-transcoding
Add JSON support to quickjs-wasm-rs and CLI
- Loading branch information
Showing
11 changed files
with
47 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::serialize::de::Deserializer; | ||
use crate::serialize::ser::Serializer; | ||
use crate::{Context, Value}; | ||
use anyhow::Result; | ||
|
||
pub fn transcode_input(context: &Context, bytes: &[u8]) -> Result<Value> { | ||
let mut deserializer = serde_json::Deserializer::from_slice(bytes); | ||
let mut serializer = Serializer::from_context(context)?; | ||
serde_transcode::transcode(&mut deserializer, &mut serializer)?; | ||
Ok(serializer.value) | ||
} | ||
|
||
pub fn transcode_output(val: Value) -> Result<Vec<u8>> { | ||
let mut output = Vec::new(); | ||
let mut deserializer = Deserializer::from(val); | ||
let mut serializer = serde_json::Serializer::new(&mut output); | ||
serde_transcode::transcode(&mut deserializer, &mut serializer)?; | ||
Ok(output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters