Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

karate - Get json value with hyphen from response

I have seen the note about quoting json fields with hyphens but how do we access json from the response if it has hyphens?

Response is along the lines of

{ cancel-account: "Please don't do it!" }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should work,

* def response = { cancel-account: "Please don't do it!" }
* def cancelAccount = response['cancel-account']
* print cancelAccount

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...