Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SlowCheetah to transform an array elements in Json config file?

It's my first time using SlowCheetah for JSON config file. I could not find a way to let it transform an array settings. For example, if my base config file has this setting:

{
  "Settings" :  [1, 2, 3] 
}

and I want to transfer it to:

{
  "Settings" :  [4, 5, 6] 
}

It simply does the merge, instead of replacement. Is there a way I can tell it what to do? Like the way we using xdt:Transform="Replace" in xml config file.

like image 389
John Cheng Avatar asked Jul 19 '17 22:07

John Cheng


1 Answers

This transformation will do the job:

{
  "@jdt.replace": {
    "@jdt.path": "$.Settings",
    "@jdt.value": [4,5,6]
  }
}
like image 148
Collin K Avatar answered Nov 11 '22 23:11

Collin K