Handling empty lists and empty maps with Minimal NestedText #61
-
|
Hi, I'm the maintainer of nestedtext-min-java - a Java impl of Minimal Nested Text. I'm using it for an internal authorization library currently and hit a bit of an embarrassing snag. How should I dump a dictionary item in which the value is an empty list? I have a policy that dumps out to Minimal NestedText like this: When testing, I deleted the rules for this policy and it persisted it dumped out the nested text like this: This seems to be consistent with how NestedText dumps empty lists with the dialect
But this makes it difficult to round-trip a Minimal NestedText file since the empty list is lost and it's trying to load it as a String. I can certainly handle this in my authorization library level, but if possible I would like to add some workaround in nestedtext-min-java. Any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
I hastily wrote this last night. But I think I can easily solve this in my lib by providing Java class deserializing which I've been putting off, e.g. When I originally posted this, I thought the Minimal NestedText format should possibly be augmented by allowing inline list and inline map specifically for the case of representing empty list or empty map, e.g.: But I no longer think it's necessary. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, with Minimal NestedText it is not possible to represent an empty list or dictionary. I recommend instead using an empty end-of-line string and using a Schema to do the conversion where it makes sense to do so. It sounds like you came to a similar conclusion. If that is not adequate, then I recommend implementing full NestedText. |
Beta Was this translation helpful? Give feedback.
Yes, with Minimal NestedText it is not possible to represent an empty list or dictionary. I recommend instead using an empty end-of-line string and using a Schema to do the conversion where it makes sense to do so. It sounds like you came to a similar conclusion. If that is not adequate, then I recommend implementing full NestedText.