1
* def now = "2022-03-21 04:30:01"
* def data = karate.jsonPath(read("data.csv"),'$[?(@.TC_ID=="'+TC_ID+'")]')

Records in csv file


|TC_ID  |DATA                           |
|TC_0001|{"VALUE1":"","VALUE2":'#(now)'}|
|TC_0001|{"VALUE1":"","VALUE2":"<now>"} |

How to replace VALUE2 field value with "now" variable? Trying to use replace function but I think it only works with text enclosed with single quotes.

Main goal is for VALUE2 json field to dynamically have the current datetime value in YYYY-MM-DD hh:mm:ss format

Don
  • 163
  • 12
  • 1
    can you please read this answer and try again. you can't put JSON into CSV files easily, so assume that some of what you want is not possible: https://stackoverflow.com/a/56581365/143475 | https://stackoverflow.com/a/62449166/143475 – Peter Thomas Mar 21 '22 at 02:39

0 Answers0