-
Notifications
You must be signed in to change notification settings - Fork 59
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
Keep original order of JSON properties #92
Comments
Hi Udo, The look-up of fields (and methods) is done via the If that assumption holds true, then your solution is pretty much all there is to it and it's thereby certainly possible. |
Hi Carsten, thank you for the fast answer. final Map<String, JsonNode> targetFields = new LinkedHashMap<>();
final Map<String, JsonNode> targetMethods = new LinkedHashMap<>(); ... and it works fine as expected, unit tests are green :). |
Hi Udo, I‘m not concerned about the existing unit tests, since they don’t check for the order of anything. Or are you talking about your own unit tests? I was more interested in whether the properties are actually in the declaration order then and not some random or still alphabetic order. |
Hi Carsten, yes, they are in the declaration order (no own unit tests). |
Hi Udo, I tried it now myself but can unfortunately not confirm your observation that the declaration order is being preserved. I'm open to alternative suggestions. 😉 |
Hi Carsten, mh, in my case there are only member variables and therefore it works in my little world. I'll have a look if there is a way to solve it (it will last a few days). Thank you so long! |
Hi Carsten, I extended So I will call I'm sorry to guide you on the wrong track. |
Hi @udowal, nothing to be sorry about. It's a valid concern. I guess especially so if the generated schema is supposed to be used in contexts like the automatic generation of UI forms. I also investigated a bit and it seems like Maybe the generator could offer some way of configuring the desired sorting method – by default: the current alphabetic sorting of the property names – where one could either not sort at all and hope the compiler preserved the declaration order and/or sort by these kinds of annotations (or some other means). Let's maybe keep this issue here open until this has been addressed. |
Hi Carsten, yes, in my project UI forms are generated automatically. I'm looking forward to the extension. Best regards |
The ability to sort an object's properties has been added to the This will be included in the next release v4.12.0 then. |
Release v4.12.0 has been published now. If you trust your compiler, you can simply configure the new property sorting configuration to always return zero ( |
Hi Carsten, simple and fast. Best regards |
Hi @CarstenWickner - is the configuration for sorting an object's properties also available in the Maven plugin, and if so, how is this expressed in the plugin's configuration? Thanks. |
Hi @neumannm, You'd have to wrap your desired configuration into an implementation of the Unless you're using the |
Hi,
in my project I need to keep the original order of JSON properties.
In "SchemaGenerationContextImpl.generateObjectDefinition (ResolvedType, ObjectNode)" the 2 lines
could be replaced by something like this:
with the new method
shouldKeepOriginalPropertiesOrder()
and a new appropriate option.Is it possible?
Best regards
Udo
The text was updated successfully, but these errors were encountered: