markap14 commented on code in PR #7745:
URL: https://github.com/apache/nifi/pull/7745#discussion_r1496517940
##########
nifi-docs/src/main/asciidoc/record-path-guide.adoc:
##########
@@ -945,6 +949,27 @@ The following record path expression would return:
| `unescapeJson(/json_str)` | {"name"="John", "age"=30} (as a Map)
|==========================================================
+*Note* that Maps cannot be serialised with a RecordSetWriter.
+
+Given a record such as:
+
+----
+{
+ "json_str": "{\"name\":\"John\",\"age\":30,\"addresses\"[{\"address_1\":
\"123 Fake Street\"}]}"
+}
+----
+
+The following record path expression would return:
+
+|==========================================================
+| RecordPath | Return value
+| `unescapeJson(/json_str, 'false')` | {"name"="John", "age"=30,
"addresses"=[{address_1"="123 Fake Street"}]} (as a Map, with each entry in
"addresses" as a Map)
+| `unescapeJson(/json_str, 'true', 'false')` | {"name": "John", "age": 30,
"addresses"=[{address_1"="123 Fake Street"}]} (as a Record, with each entry in
"addresses" as a Map)
+| `unescapeJson(/json_str, 'true', 'true')` | {"name": "John", "age": 30,
"addresses": [{"address_1": "123 Fake Street"}]} (as a Record, with each entry
in "addresses" as a Record)
+|==========================================================
+
+*Note* that Maps cannot be serialised with a RecordSetWriter.
Review Comment:
This is the third time that this is stated in the documentation for
`unescapeJson`. I think stating it once is enough.
##########
nifi-docs/src/main/asciidoc/record-path-guide.adoc:
##########
@@ -894,7 +894,11 @@ The following record path expression would convert the
record into an escaped JS
=== unescapeJson
Converts a stringified JSON element to a Record, Array or simple field (e.g.
String), using the UTF-8 character set.
-Optionally convert JSON Objects parsed as Maps into Records (defaults to
false).
+Optionally convert JSON Objects parsed as Maps into Records (defaults to
false), recursively (defaults to false).
Review Comment:
Can you clarify this statement? I.e., explicitly state the arguments that
the function takes, their names, and whether or not they are required?
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestUpdateRecord.java:
##########
@@ -232,16 +235,20 @@ public void testChangingSchema() throws
InitializationException, IOException {
final JsonTreeReader jsonReader = new JsonTreeReader();
runner.addControllerService("reader", jsonReader);
- final String inputSchemaText = new
String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-name-record.avsc")));
- final String outputSchemaText = new
String(Files.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-name-string.avsc")));
+ final String inputSchemaText = new String(Files
+
.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-name-record.avsc")));
+ final String outputSchemaText = new String(Files
+
.readAllBytes(Paths.get("src/test/resources/TestUpdateRecord/schema/person-with-name-string.avsc")));
- runner.setProperty(jsonReader,
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY,
SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
+ runner.setProperty(jsonReader,
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY,
+ SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
runner.setProperty(jsonReader, SchemaAccessUtils.SCHEMA_TEXT,
inputSchemaText);
runner.enableControllerService(jsonReader);
final JsonRecordSetWriter jsonWriter = new JsonRecordSetWriter();
runner.addControllerService("writer", jsonWriter);
- runner.setProperty(jsonWriter,
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY,
SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
+ runner.setProperty(jsonWriter,
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY,
+ SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
Review Comment:
There are a huge number of edits to this file, but almost all of them appear
to be inserting arbitrary newlines that are not necessary. Can we fix that?
##########
nifi-docs/src/main/asciidoc/record-path-guide.adoc:
##########
@@ -945,6 +949,27 @@ The following record path expression would return:
| `unescapeJson(/json_str)` | {"name"="John", "age"=30} (as a Map)
|==========================================================
+*Note* that Maps cannot be serialised with a RecordSetWriter.
Review Comment:
This seems to be a restatement of the above comment (though the above
comment seems more clear to me). Does it make sense to remove this?
##########
nifi-docs/src/main/asciidoc/record-path-guide.adoc:
##########
@@ -945,6 +949,27 @@ The following record path expression would return:
| `unescapeJson(/json_str)` | {"name"="John", "age"=30} (as a Map)
|==========================================================
+*Note* that Maps cannot be serialised with a RecordSetWriter.
+
+Given a record such as:
+
+----
+{
+ "json_str": "{\"name\":\"John\",\"age\":30,\"addresses\"[{\"address_1\":
\"123 Fake Street\"}]}"
+}
+----
+
+The following record path expression would return:
+
+|==========================================================
+| RecordPath | Return value
+| `unescapeJson(/json_str, 'false')` | {"name"="John", "age"=30,
"addresses"=[{address_1"="123 Fake Street"}]} (as a Map, with each entry in
"addresses" as a Map)
+| `unescapeJson(/json_str, 'true', 'false')` | {"name": "John", "age": 30,
"addresses"=[{address_1"="123 Fake Street"}]} (as a Record, with each entry in
"addresses" as a Map)
Review Comment:
In these two lines, it looks like the `address_1` field is not properly
quoted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]