3 ms·
I think I'm misunderstanding you, but StrictYAML's biggest departure from YAML is that it doesn't try to guess types at all. Everything is decoded as a string b
by hombre_fatal 4y ago
I think I'm misunderstanding you, but StrictYAML's biggest departure from YAML is that it doesn't try to guess types at all. Everything is decoded as a string by default until you specify otherwise with its schema system.
Here you can use `NullNone` to parse `null` into None.
from strictyaml import Map, NullNone, Int, load
schema = Map({"a": NullNone() | Int()})
load("a: null", schema) == {"a": None}
load("a: 7777", schema) == {"a": 7777}
- Dylan16807 4y agoIt doesn't guess, but also the data can't tell it. It's not just that you get a string by default, it's that everything starts as a string and then goes through post-processing. If you want to distinguish between 'any string' and 'not a string', you can't. > Here you can use `NullNone` to parse `null` into None. That's the worst possible outcome for poor Christopher Null. The best you can do for him is use "a:" to mean null but at that point you're not really dealing with nulls, you've just gone with strings and used an empty string.