Trimming zeros in JSONArray in Karate DSL

后端 未结 1 693
一生所求
一生所求 2021-01-15 21:02

I am getting a JSON response with JSONArray having leading zeros. Example, registrationnumber = [\"0000012345\", \"0000001234\", \"000123456\"] I want to remove

相关标签:
1条回答
  • 2021-01-15 21:21

    To convert to a number just multiply by 1. You should read the docs: https://github.com/intuit/karate#type-conversion

    * def data = ["0000012345", "0000001234", "000123456"]
    * def nums = karate.map(data, function(x){ return parseInt(x) })
    * match nums == [12345, 1234, 123456]
    
    0 讨论(0)
提交回复
热议问题