Rules engine API SDK: Condition not triggering when evaluating nested JSON fields in event payload

Our rules engine conditions fail to trigger when evaluating nested JSON properties in device events. Simple flat-structure conditions work fine, but any rule referencing nested paths never fires. The rule condition syntax we’re using:

{
  "condition": "event.payload.sensor.temperature > 75",
  "action": "sendAlert"
}

Event payload structure:

{
  "deviceId": "sensor-001",
  "payload": {
    "sensor": {"temperature": 82, "unit": "F"}
  }
}

The temperature clearly exceeds 75, but the alert never triggers. Flat conditions like event.deviceId == 'sensor-001' work perfectly. We’ve verified the event schema validation passes - events are being received and stored correctly. Is there a limitation with nested JSON parsing in the oiot-23 rules engine API SDK?

Check your event schema definition in the platform. The rules engine validates event structure against the registered schema before evaluating conditions. If your schema doesn’t explicitly define the nested sensor object structure with proper types, the condition evaluation fails silently. You need to register a schema that includes all nested levels with their data types specified.

There’s a known issue with type coercion in nested JSON evaluation. Even though your temperature value is numeric in the payload, the rules engine might be treating it as a string when it’s nested. Try explicitly casting it in your condition: Number(event.payload.sensor.temperature) > 75. This forces the parser to handle the type conversion correctly.

Your nested JSON condition issue has three root causes that need to be addressed together:

Rule Condition Syntax: The oiot-23 rules engine doesn’t support standard dot notation for nested object traversal beyond the first level. You must use JSONPath syntax for any nested properties:

{
  "condition": "$.payload.sensor.temperature > 75",
  "conditionType": "JSONPATH",
  "action": "sendAlert"
}

The $ prefix indicates JSONPath mode, and you must explicitly set conditionType to JSONPATH in your rule configuration. Without this, the engine defaults to simple expression evaluation which only handles flat structures.

Alternatively, use bracket notation with the EXPRESSION type:

{
  "condition": "event['payload']['sensor']['temperature'] > 75",
  "conditionType": "EXPRESSION"
}

Both syntaxes work, but JSONPath is more robust for complex nested structures.

Nested JSON Parsing: The rules engine requires explicit type definitions for nested objects. When using nested paths, you must register a detailed event schema that includes all levels:

{
  "eventType": "sensorReading",
  "schema": {
    "deviceId": {"type": "string"},
    "payload": {
      "type": "object",
      "properties": {
        "sensor": {
          "type": "object",
          "properties": {
            "temperature": {"type": "number"},
            "unit": {"type": "string"}
          }
        }
      }
    }
  }
}

Register this schema via the API SDK before creating rules:

EventSchema schema = new EventSchema();
schema.setEventType("sensorReading");
schema.setSchema(schemaDefinition);
rulesClient.registerSchema(schema);

Without a properly registered schema, the parser doesn’t know how to interpret nested structures and fails silently.

Event Schema Validation: The rules engine performs strict schema validation before condition evaluation. Even if your events are being stored correctly, they might be failing rule-specific validation. Enable validation logging:

RuleConfig config = new RuleConfig();
config.setValidationMode("STRICT");
config.setLogValidationErrors(true);

This exposes validation failures that are otherwise hidden. Common issues include:

  • Type mismatches (string vs number)
  • Missing required nested properties
  • Schema version conflicts

Also ensure your event payloads match the schema exactly. The temperature value must be a numeric type, not a string:

{"temperature": 82}  // Correct
{"temperature": "82"}  // Wrong - will fail validation

Implement these three fixes together: use JSONPath syntax, register detailed nested schemas, and enable validation logging. Your nested condition rules should then trigger reliably.

We had the exact same problem. The issue is that the rules engine’s condition parser doesn’t support multi-level object traversal in the default expression syntax. You need to use the JSONPath query language instead of dot notation. The SDK supports it but it’s not the default. Change your rule configuration to use JSONPath mode.

I’ve seen this before - the rules engine in oiot-23 doesn’t automatically traverse nested objects beyond two levels. Your path has three levels (event.payload.sensor.temperature). You might need to flatten your event structure or use a custom expression function that handles deep nesting. Check if there’s a JSONPath function available in the SDK’s expression library.