GradDev Posted April 25, 2022 Share Posted April 25, 2022 (edited) I have a field in Processwire where I save JSON Data. Something like this: {"key1":"value1","key2":"value2"} Now, I want to filter all the pages that have "key1":"value1". I have tried escaping the double quotes with \ but did not work. How do I go ahead with this? Thanks! Edited April 25, 2022 by horst Typo: changed / to \ Link to comment Share on other sites More sharing options...
horst Posted April 25, 2022 Share Posted April 25, 2022 Isn't the escape character this one: \ ? Link to comment Share on other sites More sharing options...
GradDev Posted April 25, 2022 Author Share Posted April 25, 2022 4 minutes ago, horst said: Isn't the escape character this one: \ ? Right. I used that one but did not work. I corrected the question. But now that I dig a little further, it does not seem to be the issue with double quote escaping. It seems to be the issue with the colon (:) character being surrounded by double quotes. Now, I am trying something like following: $pages->find("textarea_simple*=:\"value1\"") And it returns the pages. But this does not: $pages->find("textarea_simple*=\":\"value1\""); Do I need to escape the colon character as well? But simply escaping it with \: does not work. Link to comment Share on other sites More sharing options...
horst Posted April 25, 2022 Share Posted April 25, 2022 I never had the need to use raw text searching upon JSON objects. Looks a bit fragile to me. Have you thought about alternative storing strategies, other field types? Link to comment Share on other sites More sharing options...
Robin S Posted April 25, 2022 Share Posted April 25, 2022 The *= operator isn't the right one to use because it doesn't match partial strings at the start. If you use the %= operator I think it will work. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now