[JSONFN-3] Ordering of Data Items with jsonfn Functions are Unpredictable Created: 27/Apr/18  Updated: 03/Jan/19  Resolved: 29/May/18

Status: Closed
Project: JSON Templating Functions
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.8

Type: Bug Priority: Neutral
Reporter: Julian Nodarse Assignee: Antonín Juran
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File CustomJsonBuilder.java     Java Source File CustomJsonTemplatingFunctions.java    
Issue Links:
Relates
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Sprint: Kromeriz 148, Kromeriz 149
Story Points: 3

 Description   

The order of the data items are unpredictable when calling the jsonfn templating functions to serialize the JCR content.

The proposed solution by the client here is to swap out all references of HashMap to LinkedHashMap within the info.magnolia.templating.jsonfn.JsonBuilder class.

In my local testing, I have created a custom set of templating functions by cloning https://git.magnolia-cms.com/projects/FORGE/repos/magnolia-jsonfn/browse/src/main/java/info/magnolia/templating/jsonfn and replacing info.magnolia.templating.jsonfn.JsonBuilder.java and info.magnolia.templating.jsonfn.JsonTemplatingFunctions.java with the custom classes I have attached.

The difference between JsonBuilder and CustomJsonBuilder are the changed references of HashMap to LinkedHashMap. CustomJsonTemplatingFunctions does require the DamTemplatingFunctions object to be passed to the JsonBuilder.



 Comments   
Comment by Antti Hietala [ 03/May/18 ]

When fixing this bug, please also include the improvements made in neat-jsonfn versions 1.0.8 and 1.0.9. https://github.com/rah003/neat-jsonfn#changes

Generated at Mon Feb 12 02:18:01 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.