Hi!
Suppose that I have a JsonNode that is structured according to the document model, but the order of groups and fields is jumbled up. Is there a way with which I can resort them according to the order in the document model?
The JsonNode is not an A12-document in of itself, it just shares the field/group-names from the document model.
You could use the IDocumentV2Visitor, which has visitField and visitGroup methods, and obtain the order from there. If you want to iterate over the DocumentModel itself, you can use the DocumentModelVisitor, as far as I know, there’s no V2 version of that. But it works a bit differently. You have to use the visitor with the DocumentModelWalker, and then you can use the same methods.
Thank you for your reply.
Your reponse has given me an idea how to resolve it. Within my method, I already get all paths with their labels and fieldtypes from the document model through a walker. Turning that into a LinkedHashMap retains the order and that information can be used to structure the JsonNode as it is being created, rather than sorting afterwards.