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
There is an expected deserialization error due to full projection not being satisfied. They way to remedy that is to redefine the schema as:
typeSchema2={
dict:Map<string,string> option
number:int option
items:int list option}
The question here is:
It is unambiguous that a missing int should always be reported. Yet for dictionaries, lists and arrays, there is an interpretation, that a missing item might mean an empty dictionary, list or array (maybe someone had their yaml serializer configured to omit serialization of empty dictionaries to save some space).
My issue is that the only way to parse such document is to define lists and dictionaries as in Schema2. But then each time I'm accessing items in such a dictionary, I have to go through an option first and there is a lot of unnecessary and hard to read code.
Maybe there could be an option to have another less strict version of AndRequireFullProjection that would allow to instantiate empty complex structures that have default initializers (lists, dictionaries, arrays, but not strings or typed structures).
As a user, if I'd be interested whether the array was there or not, I could still define my schema as this and still get full control over deserialization results:
typeSchema={
dict:Map<string,string>// I don't care, just create an empty map if the key doesn't exist
number:int // must be present or deserialization will fail
items:int list option // here I'm, interested if the key was present in yaml document so give me the option}
This was intended for discussion. I can live with what we have right now, but it gets a bit annoying and verbose.
The text was updated successfully, but these errors were encountered:
I'm reopening this one. Because of all the other stuff going on, I've had not taken the time to read your question well enough and to understand it. But I wanted to return to this one when I had some more time.
In
MapYaml.AndRequireFullProjection
with Schema:and an empty document:
# empty document
There is an expected deserialization error due to full projection not being satisfied. They way to remedy that is to redefine the schema as:
The question here is:
It is unambiguous that a missing
int
should always be reported. Yet for dictionaries, lists and arrays, there is an interpretation, that a missing item might mean an empty dictionary, list or array (maybe someone had their yaml serializer configured to omit serialization of empty dictionaries to save some space).My issue is that the only way to parse such document is to define lists and dictionaries as in
Schema2
. But then each time I'm accessing items in such a dictionary, I have to go through anoption
first and there is a lot of unnecessary and hard to read code.Maybe there could be an option to have another less strict version of
AndRequireFullProjection
that would allow to instantiate empty complex structures that have default initializers (lists, dictionaries, arrays, but not strings or typed structures).As a user, if I'd be interested whether the array was there or not, I could still define my schema as this and still get full control over deserialization results:
This was intended for discussion. I can live with what we have right now, but it gets a bit annoying and verbose.
The text was updated successfully, but these errors were encountered: