Thanks Etienne Cimon.
Let me think about it thoroughly. Here're some questions to think about:
1) Why don't just use null
instead of Json.undefined
? What are implications of such an approach? Why Json.undefined
was introduced?
2) get
and to
. It seems like the method of retrieving a value by its name with the default fallback value is missing, for example:
string name = obj.name.get!string("anonymous");
3) Just a note, I suppose the doc should advice to use:
obj["key"]
notation in first place.
Think of working with JSON string: { "type": "employee", "name": "Mike" }
. After parsing you will not be able to fetch "type"
value using dot notation, as there is already type
member sitting in any vibe.data.Json
object.
4) Why do we need vibe.data.Json
structure level at all?
Alternative to the Json
structure is Variant[string]
. For arrays one may use Variant[]
. And provide some functions like "readJson", "writeJson", and maybe some other variations.