1

I am attempting to use the Java JmesParser provided by the aws-sdk-java (I have tried v1 and now v2).

Using the test data from the JmesPath website, I am using the following JSON as my inputValue:

{
  "locations": [
    {"name": "Seattle", "state": "WA"},
    {"name": "New York", "state": "NY"},
    {"name": "Bellevue", "state": "WA"},
    {"name": "Olympia", "state": "WA"}
  ]
}

and the following String as my JMESPath expression:

locations[?state == 'WA'].name

I then have the following Java:

Expression expression = JmesPathParser.parse(expression);
JmesPathAcceptorGenerator generator = new JmesPathAcceptorGenerator(ClassName.get(model.getMetadata().getFullWaitersInternalPackageName(),
            WaitersRuntimeGeneratorTask.RUNTIME_CLASS_NAME));
generator.interpret(expression, inputValue);

The last line returns the following:

{
  "locations": [
    {"name": "Seattle", "state": "WA"},
    {"name": "New York", "state": "NY"},
    {"name": "Bellevue", "state": "WA"},
    {"name": "Olympia", "state": "WA"}
  ]
}.field("locations").filter(x0 -> x0.field("state").compare("==", x0.constant("WA"))).field("name")

I'm assuming it's the added .field() section that I need to somehow evaluate to return the result, but I can't seem to find any way to do it. How do I get it to actually run the filter against my JSON and return a result?

DraegerMTN
  • 1,001
  • 2
  • 12
  • 21
  • Are you sure those are not internal implementation details? Those classes you're using don't seem to be a documented part of the SDK. – Weeble Nov 25 '20 at 15:31

0 Answers0