Key Value Map: Non CSV values broken by use of index

Not applicable

When using a key value map to store values I had issues when using index. My specific problem was that I was storing serialised JSON and because I didn't want an array when I performed a lookup then I was using index="1".

<KeyValueMapOperations>
   <Scope>environment</Scope>
   <Get assignTo="myvariable">
      <Key>
         <Parameter>jsonString</Parameter>
      </Key>
   </Get>
</KeyValueMapOperations>

The problem was that the JSON would get truncated to only include the first attribute.

{"jsonkey":"foobarblegga"

The fix is to remove the index="1" so my assumption is that currently multiple values are stored in CSV format although I dread to think of the potential bugs if people are using multiple values and aren't removing commas from the input as that would throw off all the tools.

The way in which index actually works should really be documented as it seems to me like a very basic...

String kvValue = lookup.get(key);
kvValue.split(",").get(index + 1);
// Consider a json object which is a single value but has commas

Which is poor. There should be a more robust way to handle multiple key values or the ability to return multiple values should be removed and the process should be handled elsewhere like a JavaScript policy.

0 0 125
0 REPLIES 0