You are not logged in.
Hi ab,
i played around with the new yaml parser (thanks, zen010101 and ab for the addition)
i try to do some helper to migrate yaml/json -> ini-files and back.
For saving json/yaml in the ini need to flatten the nested objects...
So i catched this ...
Doc.InitJson('{"a":{"b":1,"c":1},d:3}');
Doc.FlattenFromNestedObjects('.');
CheckEqual(Doc.ToJson, '{"a.b":1,"a.c":1,"d":3}');I assume that “FlattenFromNestedObjects” completely flattens the nested structures.
So that this test would succeed.
Doc.InitJson('{"a":{"b":{"bb":2},"c":1},d:3}');
Doc.FlattenFromNestedObjects('.');
CheckEqual(Doc.ToJson, '{"a.b.bb":2,"a.c":1,"d":3}');But at the moment it only nesting the root - level:
{"a":{"b":{"bb":2},"c":1},d:3} -> {"a.b":{"bb":2},"a.c":1,"d":3}
So this test also fails.
Doc.InitJson('{"a":{"b":{"bb":2},"c":1},d:3}');
Doc.FlattenFromNestedObjects('.');
CheckNotEqual(Doc.ToJson, '{"a.b":{"bb":2},"a.c":1,"d":3}');Is this expected?
Thank you.
Tobias
Offline
Yes, it only flatten the root level.
It was on purpose, because it was designed and used in a specific case of a generic single level key/value property dictionary context.
For INI, you don't need to 'flatten' the nested objects.
You could use dedicated sections per object.
This is what mORMot IniToObject() does - and TSynJsonFileSettings.
Offline