0

Trying to render a Slack template in their blocks format which is json. I want to pull out text string to update them before sending off the message. The problem is that text can be an object or string. I'm getting the keys with expression ($.blocks..text), but I'd like to filter out the non-string values.

I'm looking at Filters but can't get it to work:

Filter cheapFictionFilter = filter(where("text").type(String.class).is(true));
List<String> fields = JsonPath.parse(template).read("$.blocks..text", cheapFictionFilter);

Is this possible to get only get the text value that is a string for a structure with objects like this?

{
  "text: {
    "type": "mrkdwn",
    "text": "this is some text to be rendered"
}
gph
  • 1,045
  • 8
  • 25

0 Answers0