json::JsonValue object get?

I am looking at json::JsonValue - Rust

I see has_key and remove. I don't get get (by key). Is this function not present, or am I not seeing it ? I am expecting something which is:

is value is object, lookup key in hashmap
if not, return None

There's an Index implementation.

Here's the example from that page:

let object = object!{
    foo: "bar"

assert!(object["foo"] == "bar");

Edit: If the value does not exist you get Null. So if you really want an Option, it seems like you'll need to check for Null yourself, and create the Option.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.