gjson.rs icon indicating copy to clipboard operation
gjson.rs copied to clipboard

Creating new instances of Value

Open clarkmcc opened this issue 2 years ago • 1 comments

I'd like to create new instances of each type of value. Specifically, I'm using gjson to read settings from a JSON object, but I need a fucntion that produces a default value for the setting for each accessible key. I'd like to be able to do things like this

let str = Value::String("Foobar");
let num = Value::Number(10);
let ok = Value::Bool(true);
let nothing = Value::Null;

Is this possible?

clarkmcc avatar Mar 29 '23 14:03 clarkmcc

{ "str":"Foobar", "num":10, "ok":true, "nothing":Null }

Obtain these values as default values

zhangwuqiao avatar May 30 '24 03:05 zhangwuqiao