无法识别在 csv 文件中存储和使用的用于空手道场景的 json 请求正文的正确格式 [英] Cannot identify proper format for a json request body stored and used in csv file for use in a karate scenario
问题描述
我无法确定以 csv 格式存储 json 请求正文的正确格式,然后在场景中使用 csv 文件值.
Am having trouble identifying the propert format to store a json request body in csv format, then use the csv file value in a scenario.
这在一个场景中正常工作:并请求{contextURN":urn:com.myco.here:env:booking:reservation:0987654321",individuals":[{individualURN":urn:com.myco.here:env:booking:reservation:0987654321:individual:12345678","name":{"firstName":"NUNYA","lastName":"BIDNESS"},"dateOfBirth"19-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"LANDBRANCH","countrySubdivisionCode":"WV",postalCode":25506",countryCode":USA"},objectType":INDIVIDUAL"},{individualURN":urn:com.myco.here:env:booking:reservation:0987654321:individual:23456789","name":{"firstName":"NUNYA","lastName":"BIZNESS"},"dateOfBirth"-"8"01"、地址";:{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"BRANCHLAND","countrySubdivisionCode":"WV","postalCode";25506","countryCode":"USA"},"objectType":"INDIVIDUAL"}]}'
This works properly within a scenario: And request '{"contextURN":"urn:com.myco.here:env:booking:reservation:0987654321","individuals":[{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:12345678","name":{"firstName":"NUNYA","lastName":"BIDNESS"},"dateOfBirth":"1980-03-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"LANDBRANCH","countrySubdivisionCode":"WV","postalCode":"25506","countryCode":"USA"},"objectType":"INDIVIDUAL"},{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:23456789","name":{"firstName":"NUNYA","lastName":"BIZNESS"},"dateOfBirth":"1985-03-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"BRANCHLAND","countrySubdivisionCode":"WV","postalCode":"25506","countryCode":"USA"},"objectType":"INDIVIDUAL"}]}'
但是,当按如下方式存储在 csv 文件中时(我尝试了很多其他格式变体)
However, when stored in csv file as follows (I've tried quite a number other formatting variations)
'{"contextURN":"urn:com.myco.here:env:booking:reservation:0987654321","individuals":[{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:12345678","name":{"firstName":"NUNYA","lastName":"BIDNESS"},"dateOfBirth"103-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"LANDBRANCH","countrySubdivisionCode":";,"postalCode":"25506","countryCode":"USA"},"objectType":"INDIVIDUAL"},{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:23456789","name":{"firstName":"NUNYA","lastName":"BIZNESS"},"dateOf85-"09"3-01","地址":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"BRANCHLAND","countrySubdivisionCode":"WV","postalCode":"25506";countryCode":"USA"},"objectType":"INDIVIDUAL"}]}',
'{"contextURN":"urn:com.myco.here:env:booking:reservation:0987654321","individuals":[{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:12345678","name":{"firstName":"NUNYA","lastName":"BIDNESS"},"dateOfBirth":"1980-03-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"LANDBRANCH","countrySubdivisionCode":"WV","postalCode":"25506","countryCode":"USA"},"objectType":"INDIVIDUAL"},{"individualURN":"urn:com.myco.here:env:booking:reservation:0987654321:individual:23456789","name":{"firstName":"NUNYA","lastName":"BIZNESS"},"dateOfBirth":"1985-03-01","address":{"streetAddressLine1":"1 Myplace","streetAddressLine2":"","city":"BRANCHLAND","countrySubdivisionCode":"WV","postalCode":"25506","countryCode":"USA"},"objectType":"INDIVIDUAL"}]}',
并在场景中用作:
并请求 requestBody
And request requestBody
我的测试返回javascript评估失败:";&上面的json &:1:63 在第 1 行第 63 列处缺少关闭引号 ^
my test returns an "javascript evaluation failed: " & the json above & :1:63 Missing close quote ^ in at line number 1 at column number 63
您能否指出正确的格式或我遗漏的使用错误?谢谢
Can you please identify correct formatting or the usage errors I am missing? Thanks
推荐答案
我们只是在幕后使用了一个基本的 CSV 库.我建议您推出自己的 Java 帮助程序类,它可以执行您需要的任何处理/预处理.
We just use a basic CSV library behind the scenes. I suggest you roll your own Java helper class that does whatever processing / pre-processing you need.
也请阅读此答案:https://stackoverflow.com/a/54593057/143475
我无法理解您的 JSON,但如果您试图将 JSON 放入 CSV 中,抱歉 - 这不是一个好主意.请参阅此答案:https://stackoverflow.com/a/62449166/143475
I can't make sense of your JSON but if you are trying to fit JSON into CSV, sorry - that's not a good idea. See this answer: https://stackoverflow.com/a/62449166/143475
这篇关于无法识别在 csv 文件中存储和使用的用于空手道场景的 json 请求正文的正确格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!