Java JSON文件的Mapreduce Hadoop字数示例

Java JSON文件的Mapreduce Hadoop字数示例,java,hadoop,Java,Hadoop,我正在学习Java和Hadoop,看到了无数简单txt文件的字数示例。如何将此WordCount示例应用于下面的JSON文件?我在为映射器专门读取每个JSON对象中的每一行时遇到困难 file.json: [ { "id": 124, "tweet": "Hey its a beautiful day today!" "user": "twitter_username101" }, { "id": 433, "tweet": "The worst superbowl w

我正在学习Java和Hadoop,看到了无数简单txt文件的字数示例。如何将此WordCount示例应用于下面的JSON文件?我在为映射器专门读取每个JSON对象中的每一行时遇到困难

file.json:

[
 {
  "id": 124,
  "tweet": "Hey its a beautiful day today!"
  "user": "twitter_username101"
 },
 {
  "id": 433,
  "tweet": "The worst superbowl was this year's for sure, waste of my day",
  "user": "username23"
 }
]

您可以使用jsonReader,然后通过迭代将字数应用于对象列表。

您可以使用jsonReader,然后通过迭代将字数应用于对象列表。

MapReduce在每一行上进行拆分,因此您不会一次性获得整个JSON对象。您需要为每行上的JSON.MapReduce拆分使用一种特殊的输入格式,这样您就不会一次性获得整个JSON对象。您需要为JSON使用一种特殊的输入格式。