spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riccardo Ferrari <ferra...@gmail.com>
Subject Re: How to convert Row to JSON in Java?
Date Sun, 10 Sep 2017 18:22:05 GMT
Hi Kant,

You can check the getValuesMap
<https://spark.apache.org/docs/2.2.0/api/java/org/apache/spark/sql/Row.html#getValuesMap-scala.collection.Seq->.
I found this post <https://stackoverflow.com/a/41602178/8356352> useful, it
is in Scala but should be a good starting point.
An alternative approach is combine the 'struct' and 'to_json' functions
<https://spark.apache.org/docs/2.2.0/api/java/org/apache/spark/sql/functions.html>.
I have not tested this in Java but I am using it in Python.

Best,

On Sun, Sep 10, 2017 at 1:45 AM, kant kodali <kanth909@gmail.com> wrote:

> toJSON on Row object.
>
> On Sat, Sep 9, 2017 at 4:18 PM, Felix Cheung <felixcheung_m@hotmail.com>
> wrote:
>
>> toJSON on Dataset/DataFrame?
>>
>> ------------------------------
>> *From:* kant kodali <kanth909@gmail.com>
>> *Sent:* Saturday, September 9, 2017 4:15:49 PM
>> *To:* user @spark
>> *Subject:* How to convert Row to JSON in Java?
>>
>> Hi All,
>>
>> How to convert Row to JSON in Java? It would be nice to have .toJson()
>> method in the Row class.
>>
>> Thanks,
>> kant
>>
>
>

Mime
View raw message