question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling list decoding in custom formats requires internal api

See original GitHub issue

What is your use-case and why do you need this feature? For decoding lists in the xml custom format it has a mode where lists are parsed incrementally (a list is parsed as a single element list with updates). While there is access to the previous value there is no obvious way to know how to merge them (especially with custom lists), except for the AbstractCollectionSerializer.merge function. Both functions are internal

The problem with the new approach is that formats don’t know about types (serializers do). While it is indeed correct to have decoders drive the merging, the actual way merging works can only depend on the (de)serializer. When a decoder sees a list it doesn’t even know whether it is immutable or mutable, or whether it doesn’t confirm to the List interface at all. Custom serializers could expose themselves as lists easily enough, but even in the libary, there are many different types supported by children of AbstractCollectionSerializer (whose internal state makes it even harder to write a custom serializer for this case).

Describe the solution you’d like I’m not sure what the best solution is. Perhaps the best solution would be to introduce a “MergeableDeserializerStrategy” interface with a merge function. Decoders could then check for this interface and merge appropriately. There may be a parameter for merge mode.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pdvriezecommented, Aug 20, 2020

I think that perhaps an interface (an similar interfaces for things like ByteArrays and others) would allow custom serializers a bit more freedom. Of course AbstractCollectionSerializer is quite broad already.

0reactions
elizarovcommented, Aug 20, 2020

Can you give an example of XML you are trying to (de)serialize? Do you need only merging of lists (collections)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

codecs — Codec registry and base classes — Python 3.11.1 ...
This module defines base classes for standard Python codecs (encoders and decoders) and provides access to the internal Python codec registry, which manages...
Read more >
JSON Decoding in Swift with Codable: A Practical Guide
Decoding JSON Data is a fundamental part of modern iOS apps. This comprehensive guide covers all the aspects of the Codable protocols in ......
Read more >
WebCodecs - W3C
Abstract. This specification defines interfaces to codecs for encoding and decoding of audio, video, and images.
Read more >
Best Practices for API Error Handling - Nordic APIs
Before we dive deeper into error codes and what makes a “good” code “good,” we need to address the HTTP Status Codes format....
Read more >
Introduction to the Event API | New Relic Documentation
Intro to New Relic's Event API, which lets you send custom event data to your ... Before creating custom events or attributes, review...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found