martin-helmich/phpunit-json-assert

Arrays

sergeysrabionyan opened this issue · 1 comments

Hi my json looks like this

{
"data": [
{
"id": 55,

How can I correctly describe the scheme so that the asserts works? im need
assertJsonDocumentMatchesSchema method.

[
'type' => 'object',
'properties' => [
'data' => ['type' => 'array',properties=>[
'id'=>['type'=>'int']]]
This approach does not work

This is nothing special or exclusive to this library -- it just uses JSON schemas as described by the official JSON schema specification. Please have a look at the official JSON schema docs for more information.

In your case, it'd probably be

'data' => [
  'type' => 'array',
  'items' => [
    'properties' => [...]
  ]
]