-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
49 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
grails-app/controllers/io/xh/hoist/admin/BaseJsonSearchController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This file belongs to Hoist, an application development toolkit | ||
* developed by Extremely Heavy Industries (www.xh.io | [email protected]) | ||
* | ||
* Copyright © 2025 Extremely Heavy Industries Inc. | ||
*/ | ||
|
||
package io.xh.hoist.admin | ||
|
||
import com.jayway.jsonpath.Configuration | ||
import com.jayway.jsonpath.JsonPath | ||
import com.jayway.jsonpath.Option | ||
import io.xh.hoist.BaseController | ||
|
||
class BaseJsonSearchController extends BaseController { | ||
|
||
private Configuration matchSearchConf = Configuration.builder() | ||
.options( | ||
Option.SUPPRESS_EXCEPTIONS, | ||
Option.ALWAYS_RETURN_LIST | ||
).build() | ||
|
||
private Configuration nodeSearchConf = Configuration.builder() | ||
.options( | ||
Option.AS_PATH_LIST, | ||
Option.ALWAYS_RETURN_LIST | ||
).build() | ||
|
||
def getMatchingNodes(String json, String path, boolean asPathList) { | ||
def ret = JsonPath.using(nodeSearchConf).parse(json).read(path) | ||
renderJSON(ret) | ||
} | ||
|
||
protected hasPathMatch(String json, String path) { | ||
def result = JsonPath.using(matchSearchConf).parse(json).read(path) | ||
return result.size() > 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters