Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/48#discussion_r14703979
--- Diff: core/src/main/java/brooklyn/event/feed/http/JsonFunctions.java ---
@@ -132,6 +133,22 @@ private JsonFunctions() {} // instead use static
utility methods
};
}
+ /**
+ * returns an element from a json object given a full path {@link
com.jayway.jsonpath.JsonPath}
+ */
+ public static Function<JsonElement,? extends JsonElement>
getPath(final String element) {
+ return new Function<JsonElement, JsonElement>() {
+ @Override public JsonElement apply(JsonElement input) {
+ String jsonString = input.toString();
+ JsonParser jsonParser = new JsonParser();
+ JsonElement curr =
jsonParser.parse(JsonPath.<String>read(jsonString, element));
--- End diff --
A shame we have to parse the json a second time (rather than being able to
use the JsonElement), but I don't see any obvious alternative.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---