You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by ckmcd <gi...@git.apache.org> on 2016/03/24 19:39:34 UTC

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

GitHub user ckmcd opened a pull request:

    https://github.com/apache/nifi/pull/303

    NIFI-1660 - Enhance the expression language with jsonPath function

    Allows JSON path application in EL.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ckmcd/nifi NIFI-1660

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/303.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #303
    
----
commit 4c54a8ef9763c2cd50b44001013df27ee5778aa7
Author: Chris McDermott <ch...@hpe.com>
Date:   2016-03-24T18:10:19Z

    NIFI-1660 - Enhance the expression language with jsonPath function

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-221413761
  
    @mattyb149, How would I test a non-StringLiteralEvaluator?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64142183
  
    --- Diff: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/JsonPathEvaluator.java ---
    @@ -0,0 +1,98 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.attribute.expression.language.evaluation.functions;
    +
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Objects;
    +
    +import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
    +import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
    +
    +import com.jayway.jsonpath.Configuration;
    +import com.jayway.jsonpath.DocumentContext;
    +import com.jayway.jsonpath.InvalidJsonException;
    +import com.jayway.jsonpath.JsonPath;
    +import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
    +import com.jayway.jsonpath.spi.json.JsonProvider;
    +
    +
    +public class JsonPathEvaluator extends StringEvaluator {
    +
    +    private static final StringQueryResult NULL_RESULT = new StringQueryResult("");
    +    private static final Configuration STRICT_PROVIDER_CONFIGURATION = Configuration.builder().jsonProvider(new JacksonJsonProvider()).build();
    +    private static final JsonProvider JSON_PROVIDER = STRICT_PROVIDER_CONFIGURATION.jsonProvider();
    +
    +    private final Evaluator<String> subject;
    +    private final Evaluator<String> jsonPathExp;
    +
    +    public JsonPathEvaluator(final Evaluator<String> subject, final Evaluator<String> jsonPathExp) {
    +        this.subject = subject;
    +        this.jsonPathExp = jsonPathExp;
    +    }
    +
    +    @Override
    +    public QueryResult<String> evaluate(final Map<String, String> attributes) {
    +        final String subjectValue = subject.evaluate(attributes).getValue();
    +        if (subjectValue == null || subjectValue.length() == 0) {
    +            return NULL_RESULT;
    +        }
    +        DocumentContext documentContext = null;
    +        try {
    +            documentContext = validateAndEstablishJsonContext(subjectValue);
    +        } catch (InvalidJsonException e) {
    +            return NULL_RESULT;
    --- End diff --
    
    Instead of returning null when the incoming JSON is not valid, perhaps we should wrap the InvalidJsonException in a AttributeExpressionLanguageException and throw that, to make the error more visible to the user. Otherwise something like UpdateAttribute could succeed but getting a null value for the JSON Path result might not show up as a problem until later in the flow, making it harder to debug. If the JSON itself is bad, no JSON Path will succeed, so probably better to alert the user immediately (bulletin, e.g.)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-205343263
  
    Can someone please kick the Travis CI build.
    
    Failed tests: 
      TestStandardProcessSession.testManyFilesOpened:775 ยป OutOfMemory GC overhead l...
    
    This should work.
    
    Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-221073806
  
    I've rebase on master.  Other suggested changes are in the works.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-205345851
  
    Please ignore the request to kick the Travis build.  I rebased and that did it.   :-)



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-220807201
  
    This appears to have been based on the 0.x branch, not master (so the PR has conflicts). If you'd like to submit the PR against 0.x, do you mind updating the PR? If you'd like to submit against master, can you rebase against the latest master and force push the branch again? Please and thanks :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #303: NIFI-1660 - Enhance the expression language with jsonPath f...

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on the issue:

    https://github.com/apache/nifi/pull/303
  
    @ckmcd an example would be something like: 
    ${ hello:jsonPath( '$.${elementOfInterest}.items[0]') }
    
    Here, we are referencing an attribute within the JSON Path, so it is not a String Literal.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #303: NIFI-1660 - Enhance the expression language with jsonPath f...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on the issue:

    https://github.com/apache/nifi/pull/303
  
    Hey @ckmcd!  Looks like we missed the magical incantation to have this closed on the commit.  Would you mind closing this when you have the opportunity?
    
    Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-221658273
  
    @markap14 wrote
    > In the vast majority of use cases, I would expect that the JSON Path will be a literal string that does not reference any attributes. In this case, I would want to avoid compiling the JSON Path every time. Would recommend that if the jsonPathExp is an instance of the StringLiteralEvaluator, we pre-compile the JSON Path. We follow a similar pattern with the MatchesEvaluator for pre-compiling regular expressions, and it can make a pretty huge difference on performance.
    
    Mark, can you show me an example of how to write an expression that would not be using a StringLiteralEvaluator?
    
    Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64235176
  
    --- Diff: nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java ---
    @@ -233,6 +233,24 @@ public void testEmbeddedExpressionsAndQuotes() {
         }
     
         @Test
    +    public void testJsonPath() {
    +        final Map<String, String> attributes = new HashMap<>();
    +        attributes.put("json",
    --- End diff --
    
    Would recommend we pull the JSON out into a file in src/test/resources. Having this live in the codebase makes it very difficult to read & edit


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64142229
  
    --- Diff: nifi-docs/src/main/asciidoc/expression-language-guide.adoc ---
    @@ -1161,7 +1161,61 @@ Expressions will provide the following results:
     |=======================================================================================
     
     
    +[.function]
    +=== jsonPath
    +
    +*Description*: [.description]#The `jsonPath` function generates a string by evaluating the Subject as JSON and applying a JSON
    +  path expression. An empty string is generated if the Subject does not contain valid JSON, the _jsonPath_ is invalid, or the path
    +	does not exist in the Subject.  If the evaluation results in a scalar value, the string representation of scalar value is
    +	generated.  Otherwise a string representation of the JSON result is generated.  A JSON array of length 1 is special cased
    +	when `[0]` is a scalar, the string representation of `[0]` is generated.^1^#
    +
    +*Subject Type*: [.subject]#String#
    +
    +*Arguments*:
    +	 [.argName]#_jsonPath_# : [.argDesc]#the JSON path expression used to evaluate the Subject.#
     
    +*Return Type*: [.returnType]#String#
    +
    +*Examples*: If the "myJson" attribute is
    +
    +..........
    +{
    +  "firstName": "John",
    +  "lastName": "Smith",
    +  "isAlive": true,
    +  "age": 25,
    +  "address": {
    +    "streetAddress": "21 2nd Street",
    +    "city": "New York",
    +    "state": "NY",
    +    "postalCode": "10021-3100"
    +  },
    +  "phoneNumbers": [
    +    {
    +      "type": "home",
    +      "number": "212 555-1234"
    +    },
    +    {
    +      "type": "office",
    +      "number": "646 555-4567"
    +    }
    +  ],
    +  "children": [],
    +  "spouse": null
    +}
    +..........
    +
    +.jsonPath Examples
    +|===================================================================
    +| Expression | Value
    +| `${myJson:jsonPath('$.firstName')}` | `John`
    +| `${myJson:jsonPath('$.address.postalCode')}` | `10021-3100`
    +| `${myJson:jsonPath('$.phoneNumbers[?(@.type=="home")].number')}`^1^ | `212 555-1234`
    +| `${myJson:jsonPath('$.phoneNumbers')}` | `[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}]`
    +| `${myJson:jsonPath('$.missing-path')}` |
    +| `${myJson:jsonPath('$.bad@expression')}` |
    --- End diff --
    
    For the bad JSON Paths (missing or invalid), perhaps it should explicitly say the value is "_empty_" or something like that. I couldn't find other examples of table entries where the values were empty, but I did see one where a space was called out by _space_ to make it more explicit and visible.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #303: NIFI-1660 - Enhance the expression language with jso...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd closed the pull request at:

    https://github.com/apache/nifi/pull/303


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-221019823
  
    @mattyb149, @markap14  I am working on your suggestions.  Thanks.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #303: NIFI-1660 - Enhance the expression language with jsonPath f...

Posted by ckmcd <gi...@git.apache.org>.
Github user ckmcd commented on the issue:

    https://github.com/apache/nifi/pull/303
  
    This pull request should be good to go as all feedback has been incorporated.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #303: NIFI-1660 - Enhance the expression language with jsonPath f...

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on the issue:

    https://github.com/apache/nifi/pull/303
  
    @ckmcd  looks good! I was able to test it locally. Unit tests are good. I did find that a Reader was opened in a unit test and not closed, which i addressed, and a couple of NOTICE files needed to be updated. Otherwise, all is good. Pushed to master and 0.x branches. Thanks for contributing this back!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64142161
  
    --- Diff: nifi-commons/nifi-expression-language/pom.xml ---
    @@ -56,5 +56,13 @@
                 <groupId>org.apache.nifi</groupId>
                 <artifactId>nifi-utils</artifactId>
             </dependency>
    +        <dependency>
    +            <groupId>com.jayway.jsonpath</groupId>
    +            <artifactId>json-path</artifactId>
    +        </dependency>
    +		<dependency>
    --- End diff --
    
    Nit-pick for consistent whitespace/indentation for the dependencies


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the pull request:

    https://github.com/apache/nifi/pull/303#issuecomment-221464093
  
    @ckmcd not sure what you mean. If you're referring to the test I suggested adding, it would be just like the valid JSON test but missing the last brace, so the attribute would be set but the content is not valid JSON.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64234770
  
    --- Diff: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/JsonPathEvaluator.java ---
    @@ -0,0 +1,98 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.attribute.expression.language.evaluation.functions;
    +
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Objects;
    +
    +import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
    +import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
    +
    +import com.jayway.jsonpath.Configuration;
    +import com.jayway.jsonpath.DocumentContext;
    +import com.jayway.jsonpath.InvalidJsonException;
    +import com.jayway.jsonpath.JsonPath;
    +import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
    +import com.jayway.jsonpath.spi.json.JsonProvider;
    +
    +
    +public class JsonPathEvaluator extends StringEvaluator {
    +
    +    private static final StringQueryResult NULL_RESULT = new StringQueryResult("");
    +    private static final Configuration STRICT_PROVIDER_CONFIGURATION = Configuration.builder().jsonProvider(new JacksonJsonProvider()).build();
    +    private static final JsonProvider JSON_PROVIDER = STRICT_PROVIDER_CONFIGURATION.jsonProvider();
    +
    +    private final Evaluator<String> subject;
    +    private final Evaluator<String> jsonPathExp;
    +
    +    public JsonPathEvaluator(final Evaluator<String> subject, final Evaluator<String> jsonPathExp) {
    +        this.subject = subject;
    +        this.jsonPathExp = jsonPathExp;
    +    }
    +
    +    @Override
    +    public QueryResult<String> evaluate(final Map<String, String> attributes) {
    +        final String subjectValue = subject.evaluate(attributes).getValue();
    +        if (subjectValue == null || subjectValue.length() == 0) {
    +            return NULL_RESULT;
    +        }
    +        DocumentContext documentContext = null;
    +        try {
    +            documentContext = validateAndEstablishJsonContext(subjectValue);
    +        } catch (InvalidJsonException e) {
    +            return NULL_RESULT;
    +        }
    +
    +        final JsonPath compiledJsonPath = JsonPath.compile(jsonPathExp.evaluate(attributes).getValue());
    --- End diff --
    
    In the vast majority of use cases, I would expect that the JSON Path will be a literal string that does not reference any attributes. In this case, I would want to avoid compiling the JSON Path every time. Would recommend that if the jsonPathExp is an instance of the StringLiteralEvaluator, we pre-compile the JSON Path. We follow a similar pattern with the MatchesEvaluator for pre-compiling regular expressions, and it can make a pretty huge difference on performance.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1660 - Enhance the expression language wit...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/303#discussion_r64142194
  
    --- Diff: nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java ---
    @@ -233,6 +233,24 @@ public void testEmbeddedExpressionsAndQuotes() {
         }
     
         @Test
    +    public void testJsonPath() {
    +        final Map<String, String> attributes = new HashMap<>();
    +        attributes.put("json",
    +                "{" + "\n  \"firstName\": \"John\"," + "\n  \"lastName\": \"Smith\"," + "\n  \"isAlive\": true," + "\n  \"age\": 25," + "\n  \"address\": {"
    +                        + "\n    \"streetAddress\": \"21 2nd Street\"," + "\n    \"city\": \"New York\"," + "\n    \"state\": \"NY\","
    +                        + "\n    \"postalCode\": \"10021-3100\"" + "\n  }," + "\n  \"phoneNumbers\": [" + "\n    {" + "\n      \"type\": \"home\","
    +                        + "\n      \"number\": \"212 555-1234\"" + "\n    }," + "\n    {" + "\n      \"type\": \"office\","
    +                        + "\n      \"number\": \"646 555-4567\"" + "\n    }" + "\n  ]," + "\n  \"children\": []," + "\n  \"spouse\": null" + "\n}");
    +        verifyEquals("${json:jsonPath('$.firstName')}", attributes, "John");
    +        verifyEquals("${json:jsonPath('$.address.postalCode')}", attributes, "10021-3100");
    +        verifyEquals("${json:jsonPath(\"$.phoneNumbers[?(@.type=='home')].number\")}", attributes, "212 555-1234");
    +        verifyEquals("${json:jsonPath('$.phoneNumbers')}", attributes,
    +                "[{\"type\":\"home\",\"number\":\"212 555-1234\"},{\"type\":\"office\",\"number\":\"646 555-4567\"}]");
    +        verifyEquals("${json:jsonPath('$.missing-path')}", attributes, "");
    +        verifyEquals("${missing:jsonPath('$.bad@expression')}", attributes, "");
    +    }
    --- End diff --
    
    Perhaps add a test for an existing attribute containing invalid JSON.  If the behavior on bad JSON is changed to throw an exception (see above comment), a test could verify that; otherwise it should be tested for null.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---