-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type pattern "@...@" is not supported by TextMatcher. #432
Comments
Hey, your example does not have a valid JSON, because of that PHPMatcher thinks this is just a regular text. {
"aws": {
"key": "laclédepassepartout",
"secret": "lesecretdupèrefouras",
- "@...@"
}
} |
Hey, it's not the Json, but the Json Pattern, the Json is ok in the variable It should work when I read the documentation the https://github.com/coduo/php-matcher#json-matching-with-unbounded-arrays-and-objects Json matching with unbounded arrays and objects<?php
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match(
'{
"users":[
{
"firstName": "Norbert",
"lastName": "Orzechowicz",
"created": "2014-01-01",
"roles":["ROLE_USER", "ROLE_DEVELOPER"],
"attributes": {
"isAdmin": false,
"dateOfBirth": null,
"hasEmailVerified": true
},
"avatar": {
"url": "http://avatar-image.com/avatar.png"
}
},
{
"firstName": "Michał",
"lastName": "Dąbrowski",
"created": "2014-01-01",
"roles":["ROLE_USER", "ROLE_DEVELOPER", "ROLE_ADMIN"],
"attributes": {
"isAdmin": true,
"dateOfBirth": null,
"hasEmailVerified": true
},
"avatar": null
}
]
}',
'{
"users":[
{
"firstName": "@string@",
"lastName": "@string@",
"created": "@string@.isDateTime()",
"roles": [
"ROLE_USER",
"@...@"
],
"attributes": {
"isAdmin": @boolean@,
"@*@": "@*@"
},
"avatar": "@json@.match({\"url\":\"@string@.isUrl()\"})"
}
,
@...@
]
}'
); |
@tentacode can you try like this? :
|
@domis86 is right here, you should use "@*@" if you just want wildcard, There is also no such thing as "Json Pattern", in order to match value against pattern, json matcher must turn both of them into arrays, it's impossible to achieve that when pattern is not even a JSON. |
Looks like PHPMatcher uses TextMatcher instead of JsonMatcher, and I can't use any of the cool JSON matcher…
Is there a way to force JSON matcher ?
The text was updated successfully, but these errors were encountered: