ColdFusion > 2016. SerializeJSON preserve Order with duplicate items

Viewed 176

I am using myStruct=createObject("java", "java.util.LinkedHashMap").init(); to create a JSON structure using SerializeJSON. I have followed following thread.

But I came across following challenge:

I am given a JSON structure in which there are 2 child items have same key. If you look below, "item" key is the same for both children under "items". And order need to be preserved.

   {
   "Items" : {
        "item": {
          "itemId": "1",
          "name": "item1 descr",
        },
        "item": {
          "itemId": "222",
          "name": "item2 descr",
        }
      }
 }

How to create a structure so that SerializeJSON works and order is preserved as shown above. Thanks for your help!

Note: ColdFusion > 2016. So new ideas should work,

1 Answers
Related