AnsweredAssumed Answered

dictionary{} processing

Question asked by jamesfreddyc Champion on Feb 13, 2019
Latest reply on Feb 13, 2019 by dkwiens

Looking for most efficient method to update a dictionary that I'm populating from a REST map service and then attempting to alter as needed.  The desired alteration is simple: duplicate each item and swap value in two of the attributes of the newly copied item.  Best way to describe is just show current vs. desired output below!

 

(attributes "juncA" and "juncB" must have their values swapped on copied item).

 

Current:

{
  "junctionMatrix": [
    {
      "attributes": {
        "WCU": "C1",
        "calcMethod": "AERIAL",
        "juncA": "S47D",
        "juncB": "CR-03.0",
        "juncDistance": 8501.86072183
      }
    },
    {
      "attributes": {
        "WCU": "C1",
        "calcMethod": "AERIAL",
        "juncA": "S47B_C",
        "juncB": "S47D_S",
        "juncDistance": 17535.28122721
      }
    }
   ]
} 

 

Desired:

{
  "junctionMatrix": [
    {
      "attributes": {
        "WCU": "C1",
        "calcMethod": "AERIAL",
        "juncA": "S47D",
        "juncB": "CR-03.0",
        "juncDistance": 8501.86072183
      }
    },
    {
      "attributes": {
      "WCU": "C1",
      "calcMethod": "AERIAL",
      "juncA": "CR-03.0",
      "juncB": "S47D",
      "juncDistance": 8501.86072183
    }
    },
    {
      "attributes": {
        "WCU": "C1",
        "calcMethod": "AERIAL",
        "juncA": "S47B_C",
        "juncB": "S47D_S",
        "juncDistance": 17535.28122721
      }
    },
    {
      "attributes": {
        "WCU": "C1",
        "calcMethod": "AERIAL",
        "juncA": "S47D_S",
        "juncB": "S47B_C",
        "juncDistance": 17535.28122721
      }
    }
   ]
}

Outcomes