Uploaded image for project: 'Common Controller SDK'
  1. Common Controller SDK
  2. CCSDK-3168

The "toJsonString" method in SvcLogicContext returns incorrect jsonString for Large Array

XMLWordPrintable

      When we convert a series of array attributes in context memory to Json/JsonString using toJsonString function inside SvcLogicContext, If the length of the Array is bigger then 10, the method doesn't work properly.

      The cause of this issue is a inappropriate Treemap usage inside "toJsonString" implemetation. "toJsonString" puts all the attributes into Treemap to sort the key before convert the attributes  to Json. Its correct functioning depends on this sorting order. However, Treemap sorts the key in alphabetical order, whereas the correct sort order for context memory should be so-called natural sort order. For instance, if an array attribute inside context memory has more then 10 elements. The sorted key is "bigArr[0]", bigArr[10]",.... the correct order should be "bigArr[0], bigArr[1], bigArr[2], ..., ..., bigArr[9], bigArr[10], ... ". 

      To whom it may concern, we have provided a fix for this issue. Inside which, a customized natural sorting treemap is provided.

            dzhang2020huawei dzhang2020huawei
            dzhang2020huawei dzhang2020huawei
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: