google / google/built_value.dart

Serialization fields order

Open
#749 1 comment 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
p2 / feature request
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

I have an environment in which the order of the elements serialized is important.
I expected built_value to serialize fields in the order in which they are defined.
But I have seen that first non nullable field are listed and the nullable ones.
Is it possible to change this behavior?
I thought in creating a plugin for reordering fields, but I couldn't find a way to discover the original declaration order.
Finally I created my custom serializer, simply taking the standard one and changing the order in which the field are defined.
This works, but creating custom serializer for all classes is a big work (I just did for the main one), and I'd like to have the less custom serializers that I can.
Any hint?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.