次のjson文字列があります:
{"guid": "4bad1d9a-180f-4751-a698-4aac07b1eac7","partition":1,"roles": []}
specs2 の org.specs2.matcher.JsonMatchers を使用して、guid とパーティションを強制することができました。
json must /("guid" -> "4bad1d9a-180f-4751-a698-4aac07b1eac7")
json must /("partition" -> 1)
しかし、「ロール」が存在し、「空の配列である」ことを強制する正しい構文を理解できません。これは実行可能ですか?
編集:
コメンターの質問に従って、私は次のことを試しました:
json must /("roles" -> "[]")
その結果、次のテストが失敗します。
[error] {guid : 5ad4c4c5-4fdb-461b-9883-b84ff3b84610,partition : 1.0,roles : []} doesn't contain 'roles' : '[]'