You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to define a json structure to provide serialization and deserialization capabilities, but I encountered two problems.
No mapping of dictionary type
Unable to define recursive types (direct or indirect)
package endec: [email protected];
worldimports {
exporttypes;
}
interfacetypes {
/// The json value contextrecordjson {
/// The root valueroot:value
}
/// A json valuevariantvalue {
%null,
%bool(bool),
%decimal(f64),
%string(string),
%array(array),
%object(object)
}
/// A json arrayrecordarray {
%list:list<value>,
}
/// A json objectrecordobject {
%dict:list<tuple<string, value>>,
}
}
Such a definition will report an error:
called `Result::unwrap()` on an `Err` value: failed to parse package: C:\Users\CLionProjects\serde-wasi\projects\serde-json\witCaused by:
type `value` depends on itself--> C:\Users\CLionProjects\serde-wasi\projects\serde-json\wit\world.wit:11:15|11 | root: value| ^----
The text was updated successfully, but these errors were encountered:
Currently value types are not allowed to be recursive, which is the root problem here. It's definitely valuable and tracked as a future feature in #56, it's just a ton of effort and complexity so we were planning to postpone it until after the 1.0/MVP. Until then, the best approximation is to define JSON via resource types (which admittedly isn't very efficient due to the function call overhead, so you might also just want to pass JSON as a string or BSON list<u8>).
I want to define a json structure to provide serialization and deserialization capabilities, but I encountered two problems.
Such a definition will report an error:
The text was updated successfully, but these errors were encountered: