I tried to parse the schema property (from the Schema object) in Python, which is a byte array. However, decoding this gives many decoding error that I can’t seem to solve.
For example, at the sc-tools(https://sctools.mainnet.concordium.software/) front end, we display the schema at the front-end as a JSON-template, by invoking the to_json_template rust-binding:
Thank you. Tried that, cargo complained about Failed to resolve: use of undeclared crate or module serde_json , which I added in cargo.toml, leading to the next set of build errors:
❯ cargo build
Compiling ccdexplorer-schema-parser v0.1.9 (/Users/sander/Developer/open_source/ccdexplorer-schema-parser)
error[E0308]: mismatched types
--> src/lib.rs:83:18
|
73 | ) -> PyResult<serde_json::value::Value> {
| ---------------------------------- expected `Result<serde_json::Value, PyErr>` because of return type
...
83 | Ok(s) => s.to_json_template() ,
| ^^^^^^^^^^^^^^^^^^^^ expected `Result<Value, PyErr>`, found `Value`
|
= note: expected enum `Result<serde_json::Value, PyErr>`
found enum `serde_json::Value`
help: try wrapping the expression in `Ok`
|
83 | Ok(s) => Ok(s.to_json_template()) ,
| +++ +
error[E0277]: the trait bound `Result<serde_json::Value, PyErr>: OkWrap<_>` is not satisfied
--> src/lib.rs:68:1
|
68 | #[pyfunction]
| ^^^^^^^^^^^^^ the trait `OkWrap<_>` is not implemented for `Result<serde_json::Value, PyErr>`
|
= help: the trait `OkWrap<T>` is implemented for `Result<T, E>`
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `ccdexplorer-schema-parser` (lib) due to 2 previous errors```
❯ cargo build
Compiling ccdexplorer-schema-parser v0.1.9 (/Users/sander/Developer/open_source/ccdexplorer-schema-parser)
error[E0277]: the trait bound `Result<serde_json::Value, PyErr>: OkWrap<_>` is not satisfied
--> src/lib.rs:68:1
|
68 | #[pyfunction]
| ^^^^^^^^^^^^^ the trait `OkWrap<_>` is not implemented for `Result<serde_json::Value, PyErr>`
|
= help: the trait `OkWrap<T>` is implemented for `Result<T, E>`
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `ccdexplorer-schema-parser` (lib) due to 1 previous error