Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added small toAA function #617

Closed
wants to merge 1 commit into from
Closed

Conversation

UplinkCoder
Copy link
Contributor

added small function to get an AA
(e.g. for serializeToJson)
does not handle extended fields though.

added small function to get an AA
(e.g. for serializeToJson)
does not handle extended fields though.
@UplinkCoder
Copy link
Contributor Author

at a long term it would maybe pay to make the serializeTo functions DictionaryList-aware.
But I have no Idea how to go about that

@s-ludwig
Copy link
Member

A few points to think about:

  • A DictionaryList can contain multiple values per key
  • Key may have different case, but are compared case insensitive
  • The insertion order is preserved

These all make the AA conversion lossy, which would be an issue especially when using it for (de)serialization. I'm wondering what would be the best interface here, asAA, toAA or opCast(T)() if(is(T == Value[string])). I'm leaning towards opCast as the most idiomatic D - plus a cast also makes it a bit more obvious that there might be lost information.

For serialization, it would have to preserve all information, so it would have to be mapped to something like Tuple!(string, Value)[]. This could be achieved by implementing toJson/fromJson methods, but this wouldn't be really pretty here. Maybe the serialization framework should support defining a more generic serialized representation, independent of the output format. I'll open a separate issue for this.

BTW, would be nice to have the white space according to the style guide.

@UplinkCoder
Copy link
Contributor Author

generic serialization is the way to go
closeing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants