如何将Spark RDD转换为JSON对象java

时间:2014-10-13 19:47:17

标签: java json cassandra apache-spark rdd

当使用Cassandra和Spark时,我恢复的RDD看起来像这样:

MAPPED RDD: [Person{id='8', name='Hans', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='7', name='Loren', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='1', name='John', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='5', name='Adam', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='6', name='Kit', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='10', name='Lacey', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='9', name='Phil', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='2', name='Anna', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='4', name='Angel', birthDate='Fri Oct 03 15:07:38 EDT 2014'}, Person{id='3', name='Andrew', birthDate='Fri Oct 03 15:07:38 EDT 2014'}]

如何让它看起来像JSON对象?现在我通过手动替换Mapped RDD的部分来使它看起来像JSON,但我想要一个函数,或者快速的方法将Spark RDD映射到JSON,因此它可以处理不同的数据RDD

0 个答案:

没有答案