-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
@JsonPropertyOrder annotation for JSON formatting #4387
Comments
Maybe @JsonAnyGetter, @JsonAnySetter may be properties/getters/setters with those annotations are not respected....? 🤔 |
EDIT: What was I thinking... 🤦♂️ |
There is #518 requesting "any properties" to be sorted (at least wrt alphabetic sorting), but I don't think anyone is working on that. The issue is that output of any-properties is quite separate from output of regular properties so there is no easy fix. But I guess the idea of using logical name of "any getter" accessor (here, |
I filed #4388 to specifically request that |
I assume #4388 is a replacement for this, so closing. |
@Jerry-X07 which version were you testing this against? |
Search before asking
Describe the bug
I have a Java class named OrderCount which is annotated with @JsonPropertyOrder from the package com.fasterxml.jackson.annotation.JsonPropertyOrder. The goal is to format the JSON output in a specific order. The desired order is: entityId, entityName, totalTests, products, and childEntities at the end. However, despite attempting to reorder the properties, I'm encountering difficulties placing childEntities at the end of the JSON output.
Specifically, when I try to change the order of
entityId
,entityName
, andtotalTests
, then it's working. However, when I try to change the order of products or childEntities, it's not working as expectedVersion Information
No response
Reproduction
No response
Expected behavior
{ "entityId": "1", "entityName": "entity1", "totalTests": 6, "productName_1":2, "productName_2":2, . . "productName_n":2, "childEntities": [ { "entityId": "2", "entityName": "entity2", "totalTests": 3, "productName_1":1, "productName_2":1, . . "productName_n":1, "childEntities": [] }, { "entityId": "3", "entityName": "entity3", "totalTests": 3, "productName_1":1, "productName_2":1, . . "productName_n":1, "childEntities": [] } ] }
But Instead of above JSON Format getting This JSON format :
{ "entityId": "1", "entityName": "entity1", "totalTests": 6, "childEntities": [ { "entityId": "2", "entityName": "entity2", "totalTests": 3, "childEntities": [], "productName_1":1, "productName_2":1, . . "productName_n":1 }, { "entityId": "3", "entityName": "entity3", "totalTests": 3, "childEntities": [], "productName_1":1, "productName_2":1, . . "productName_n":1 } ], "productName_1":2, "productName_2":2, . . "productName_n":2 }
Additional context
No response
The text was updated successfully, but these errors were encountered: