Stringify in rhai

How do I convert an object to a string for the header? rhai script for router.

let subGraphHeaders = #{
        loginName: loginName,
       isPrimary: sPrimary
    };
request.subgraph.headers["user"] = json::stringify(subGraphHeaders); // something like this

When I do it this way, it works, but I need to add more value from claims

request.subgraph.headers["user"] = `{"loginName":"${loginName}", "isPrimary":${isPrimary}}`

Can you use subGraphHeaders.to_json()? This is a Rhai feature, but I haven’t tested from within Router just yet

Yes, it’s working. Thanks