You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2018/09/26 01:53:00 UTC

[jira] [Assigned] (SPARK-25514) Generating pretty JSON by to_json

     [ https://issues.apache.org/jira/browse/SPARK-25514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hyukjin Kwon reassigned SPARK-25514:
------------------------------------

    Assignee: Maxim Gekk

> Generating pretty JSON by to_json
> ---------------------------------
>
>                 Key: SPARK-25514
>                 URL: https://issues.apache.org/jira/browse/SPARK-25514
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.4.0
>            Reporter: Maxim Gekk
>            Assignee: Maxim Gekk
>            Priority: Minor
>
> It would be nice to have an option, for example *"pretty"*, which enable special output mode for the to_json function. In the mode, produced JSON string will have easily readable representation. For example:
> {code:scala}
> val json = """[{"book":{"publisher":[{"country":"NL","year":[1981,1986,1999]}]}}]"""
> to_json(from_json('col, ...), Map("pretty" -> "true")))
> [ {
>   "book" : {
>     "publisher" : [ {
>       "country" : "NL",
>       "year" : [ 1981, 1986, 1999 ]
>     } ]
>   }
> } ]
> {code}
> There are at least two use cases:
> # Exploring content of nested columns. For example, a result of your query is a few rows, and some columns have deep nested structure. And you want to analyze and find a value of one of nested fields.
> # You already have an JSON in one of columns, and want to explore the JSON records. New option will allow to do that easily without copy-past JSON content to an editor by combining from_json and to_json functions.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org