Rust inside node.js with serde_json


I was following the chapter on Rust Inside Other Languages and I decided to try the node.js example which was simple enough to compile. What I’m struggling with is the idea of passing a json object from nodejs to a Rust function that accepts serde_json::Value.

Is this a guide somewhere that I could follow? As yet, I have not been successful in doing that.


You may want to check out


Thank you! That is exactly what I was looking for. Great talk too on the homepage.


Hi @fasihrana, I’m interested to know how you get along.

I’m currently figuring out how to use serde_json with Neon and I need help.

Compiler is asking me to impl std::convert::From for neon::vm::Throw, if I’ve understood it correctly.

error[E0277]: the trait bound `neon::vm::Throw: std::convert::From<serde_json::Error>` is not satisfied
  --> src\
23 |   let app_info: Value = serde_json::from_str(&app_info_string)?;
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<serde_json::Error>` is not implemented for `neon::vm::Throw`
   = note: required by `std::convert::From::from`

To satisfy, I’m trying variations of the following:

use neon::vm::{ Throw };
use serde_json::{ Error };

struct CustomThrow(Throw);

impl From<Error> for CustomThrow {
  fn from(error: Error) -> Self {

However, Throw is a struct,, and I’m not sure how to pass it an error value.

Thank you for any pointers.


Hi @hunterlester,

I’m not an expert and there are probably far more knowledgeable people to answer your question.

I would have simply repackaged that error to the custom type.


@fasihrana Thank you. :smiley:

Thank you to @RReverser for educating me on what was the issue.

I wanted to make sure to updated this thread, for anyone else running into this issue.

I was using the ? operator without understanding or thinking about it:

See his answer here (scroll to bottom) which is the exact solution: