libenchao commented on code in PR #13081:
URL: https://github.com/apache/flink/pull/13081#discussion_r1119750413


##########
docs/content/docs/connectors/table/formats/json.md:
##########
@@ -241,6 +241,41 @@ The following table lists the type mapping from Flink type 
to JSON type.
     </tbody>
 </table>
 
+Features
+--------
 
+### Allow top-level JSON Arrays
 
+Usually, we assume the top-level of json string is a json object. Then the 
json object is converted to one SQL row.
 
+There are some cases that, the top-level of json string is a json array, and 
we want to explode the array to
+multiple records, each one of the array is a json object which is converted to 
one row. Flink JSON Format supports
+read such data implicitly.
+
+For example, for the following SQL DDL:
+<div class="codetabs" markdown="1">
+<div data-lang="SQL" markdown="1">
+{% highlight sql %}
+CREATE TABLE user_behavior (
+  col1 BIGINT,
+  col2 DOUBLE,
+  col3 VARCHAR,
+  col4 BOOLEAN
+) WITH (
+ 'format' = 'json',
+ ...
+)
+{% endhighlight %}
+</div>
+</div>
+
+Flink JSON Format will produce 2 rows `(123, "a")` and `(456, "b")` with both 
of following two json string.
+The top-level is JSON Array:
+{% highlight json %}
+[{"col1": 123, "col2": "a"}, {"col1": 456, "col2": "b"}]
+{% endhighlight %}
+The top-level is JSON Object:
+{% highlight json %}
+{"col1": 123, "col2": "a"}
+{"col1": 456, "col2": "b"}

Review Comment:
   Yes, they are two JSON Objects, and will be deserialized into two rows.



-- 
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]

Reply via email to