add comstant
This commit is contained in:
parent
3c4618c8dc
commit
ff89f85bd1
@ -57,7 +57,7 @@ public class TbJsonPathNode implements TbNode {
|
||||
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
|
||||
this.config = TbNodeUtils.convert(configuration, TbJsonPathNodeConfiguration.class);
|
||||
this.jsonPathValue = config.getJsonPath();
|
||||
if (this.jsonPathValue != "$") {
|
||||
if (!TbJsonPathNodeConfiguration.DEFAULT_JSON_PATH.equals(this.jsonPathValue)) {
|
||||
this.configurationJsonPath = Configuration.builder()
|
||||
.jsonProvider(new JacksonJsonNodeJsonProvider())
|
||||
.build();
|
||||
@ -67,7 +67,7 @@ public class TbJsonPathNode implements TbNode {
|
||||
|
||||
@Override
|
||||
public void onMsg(TbContext ctx, TbMsg msg) throws ExecutionException, InterruptedException, TbNodeException {
|
||||
if (jsonPathValue != "$") {
|
||||
if (!TbJsonPathNodeConfiguration.DEFAULT_JSON_PATH.equals(this.jsonPathValue)) {
|
||||
try {
|
||||
JsonNode jsonPathData = jsonPath.read(msg.getData(), this.configurationJsonPath);
|
||||
ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(jsonPathData)));
|
||||
|
||||
@ -21,12 +21,13 @@ import org.thingsboard.rule.engine.api.NodeConfiguration;
|
||||
@Data
|
||||
public class TbJsonPathNodeConfiguration implements NodeConfiguration<TbJsonPathNodeConfiguration> {
|
||||
|
||||
static final String DEFAULT_JSON_PATH = "$";
|
||||
private String jsonPath;
|
||||
|
||||
@Override
|
||||
public TbJsonPathNodeConfiguration defaultConfiguration() {
|
||||
TbJsonPathNodeConfiguration configuration = new TbJsonPathNodeConfiguration();
|
||||
configuration.setJsonPath("$");
|
||||
configuration.setJsonPath(DEFAULT_JSON_PATH);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user