Java 将json对象转换为csv
我需要在java环境中转换csv中的复杂.json文件。 我已经看过了 以及在其中开发的应用程序,但它们不适用于我的文件,如以下示例所示:Java 将json对象转换为csv,java,json,export-to-csv,Java,Json,Export To Csv,我需要在java环境中转换csv中的复杂.json文件。 我已经看过了 以及在其中开发的应用程序,但它们不适用于我的文件,如以下示例所示: { "metadata": {"result_type": "recent", "iso_language_code": "it"}, "created_at": "Thu Apr 04 16: 48: 29 +0000 2013", "user": { "id": "integer", "id_
{
"metadata": {"result_type": "recent", "iso_language_code": "it"},
"created_at": "Thu Apr 04 16: 48: 29 +0000 2013",
"user": {
"id": "integer",
"id_str": "id_str",
"name": "a name and a surname",
"screen_name": "ascreenname",
"location": "Roma",
"description": "some description ",
"url": "some url",
"entities": {
"url": {
"urls": [{
"url": "other url",
"expanded_url": null,
"indices": [0, 39]
}]
},
"description": {"urls": []}
},
"notifications": null
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"entities": {
"hashtags": [
{"text": "text", "indices": [29, 35]},
{"text": "text", "indices": [36, 52]},
{"text": "roma", "indices": [53, 58]},
{"text": "ostiense", "indices": [59, 68]},
{"text": "text", "indices": [69, 79]},
{"text": "text", "indices": [80, 92]},
{"text": "text", "indices": [93, 99]}
],
"urls": [
{"url": "an url", "expanded_url": "an url", "indices": [101, 123]}
],
"user_mentions": []
},
"lang": "it"
}
您提到的这些问题应该足以解决您的特定问题,并进行一些定制。如果定制工作失败,请向我们展示代码以获取更多帮助。您提供的json数据结构不能直接映射到csv。您可能需要解析和构造一个合适的对象图,然后写回一个csv,比如说使用openCSV。不要发布一堆代码作为答案。改为编辑您的答案,只包含代码的相关部分。没有人想通过阅读大量代码来找出问题所在。可能的CSV复制是针对扁平数据行,而不是结构化数据。您需要弄清楚如何将JSON对象展平为一行值。