Replies: 1 comment
-
I didn't try it myself, but it seems to me that your problem is the
definition of sort:
sort_spec : /sort(\[.*\])?/ "=" field_list
Because it is a greedy regexp that matches *Everything*, it goes on and
catches the rest.
You have two options:
1. Use non-greedy search (i.e. *.*?* )
2. Match anything that isn't ], like *[^\]]**
Or if the stuff inside the brackets is always a word, just match a word.
Good luck!
…On Tue, Aug 10, 2021 at 9:37 PM Steve Jackson ***@***.***> wrote:
Really well-designed tool, thanks for that.
Having an issue that I can't seem to get around. I'm trying to parse
JsonAPI, but can't seem to properly split on the & of the url parameter in
isolated cases;
The problem (as shown below) is that I can't seem to get my "&" from being
part of my value if my key is sort[].
I've kind of run out of tricks now and hoping you can cure my ignorance.
Thank you, again.
?start: specs
// Define a list of specs, separated by an &
specs : spec
| [spec ("&" spec)*]
// SPEC
spec : page_spec
| sort_spec
| sparse_field_spec
// PAGINATION
page_spec : "page[number]" "=" INT -> page_number
| "page[size]" "=" INT -> page_size
// SPARSE FIELDS
// eg. fields=one or fields=one,two or fields[resource]=one,two
sparse_field_spec : /fields(\[.*\])?/ "=" field_list
// SORT
// eg. sort=one or sort=one,two or sort[resource]=one,two
sort_spec : /sort(\[.*\])?/ "=" field_list
field_list : [WORD ("," WORD)*]
WORD : /[A-Za-z]+/
%import common.INT
%import common.WS
%ignore WS
query =
"sort=one&page[number]=4&page[size]=5&sort[test]=one,two&sort[three]=five"
spec
sort_spec
sort
field_list one
spec
page_number 4
spec
page_size 5
spec
sort_spec
sort[test]=one,two&sort[three]
field_list five
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#797 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFSSSD6EJOF6PTNPR2PTOLT4FWWVANCNFSM4UZTM34Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions