{"record":{"id":"d55c142e0463bff6","repo":"apache/beam","slug":"expected-json-object-for-field-name-unable-to-convert","errorCode":null,"errorMessage":"Expected JSON object for field '{name}'. Unable to convert '{jsonValue}' to Beam Row, it is not a JSON object. Currently only JSON objects can be parsed to Beam Rows","messagePattern":"Expected JSON object for field '(.+?)'\\. Unable to convert '(.+?)' to Beam Row, it is not a JSON object\\. Currently only JSON objects can be parsed to Beam Rows","errorType":"validation","errorClass":"UnsupportedRowJsonException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java","lineNumber":345,"sourceCode":"        } else if (SqlTypes.TIME.getIdentifier().equals(identifier)) {\n          return timeValueExtractor().extractValue(fieldValue.jsonValue());\n        } else if (SqlTypes.DATETIME.getIdentifier().equals(identifier)) {\n          return localDatetimeValueExtractor().extractValue(fieldValue.jsonValue());\n        } else {\n          return extractJsonNodeValue(\n              FieldValue.of(\n                  fieldValue.name(),\n                  fieldValue.type().getLogicalType().getBaseType(),\n                  fieldValue.jsonValue()));\n        }\n      }\n\n      return extractJsonPrimitiveValue(fieldValue);\n    }\n\n    private Row jsonObjectToRow(FieldValue rowFieldValue) {\n      if (!rowFieldValue.isJsonObject()) {\n        throw new UnsupportedRowJsonException(\n            \"Expected JSON object for field '\"\n                + rowFieldValue.name()\n                + \"'. Unable to convert '\"\n                + rowFieldValue.jsonValue().asText()\n                + \"' to Beam Row, it is not a JSON object. Currently only JSON objects can be parsed to Beam Rows\");\n      }\n\n      return rowFieldValue.rowSchema().getFields().stream()\n          .map(\n              schemaField ->\n                  extractJsonNodeValue(\n                      FieldValue.of(\n                          schemaField.getName(),\n                          schemaField.getType(),\n                          rowFieldValue.jsonFieldValue(schemaField.getName()))))\n          .collect(toRow(rowFieldValue.rowSchema()));\n    }\n","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java#L327-L363","documentation":"When a schema field is itself a Row type, jsonObjectToRow requires the JSON value to be an object. If the value is any other JSON node type (string, number, array, etc.), UnsupportedRowJsonException is thrown because only JSON objects can be parsed into nested Beam Rows.","triggerScenarios":"jsonToRow where a nested-row schema field receives a non-object JSON value, e.g. \"nested\": \"text\" or \"nested\": [1,2] instead of an object.","commonSituations":"Nested data flattened differently upstream; producer emits an array of objects where a single object is expected; wrong schema version used on the reader side.","solutions":["Fix the JSON so the nested field is a JSON object matching the nested row schema","Update the schema so the field type matches the actual JSON shape (e.g. ARRAY<ROW>)","Transform the payload (wrap the value in an object) before parsing","Catch UnsupportedRowJsonException and inspect/repair the offending field"],"exampleFix":"// before\n{\"nested\": [1,2,3]}\n// after\n{\"nested\": {\"a\": 1, \"b\": 2}}","handlingStrategy":"validation","validationCode":"JsonNode n = json.get(\"nestedFieldName\");\nif (n != null && !n.isObject()) throw new IllegalArgumentException(\"Nested row field must be a JSON object\");","typeGuard":null,"tryCatchPattern":"try { Row r = RowJsonUtils.jsonToRow(mapper, json); } catch (RowJson.UnsupportedRowJsonException e) { /* handle */ }","preventionTips":["Ensure nested rows are serialized as JSON objects","Match reader schema to actual payload shape","Add schema-aware payload validation at ingestion"],"tags":["beam","json","nested-row","deserialization"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}