{"id":22488,"date":"2024-10-21T04:08:26","date_gmt":"2024-10-21T04:08:26","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=22488"},"modified":"2024-10-21T04:08:26","modified_gmt":"2024-10-21T04:08:26","slug":"convert-json-with-attributes-to-csv","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/use\/convert-json-with-attributes-to-csv.html","title":{"rendered":"Convert JSON with attributes to CSV"},"content":{"rendered":"<p>I want to\u00a0convert some NFT metadata JSON files to CSV for opensea.<\/p>\n<p>JSON data like this:<\/p>\n<pre>{\r\n  \"name\": \"5\",\r\n  \"description\": \"\",\r\n  \"external_url\": \"\",\r\n  \"image\": \"5.png\",\r\n  \"attributes\": [\r\n    {\r\n      \"trait_type\": \"Background\",\r\n      \"value\": \"DOT-6\"\r\n    },\r\n    {\r\n      \"trait_type\": \"Luckbox\",\r\n      \"value\": \"3\"\r\n    }\r\n  ],\r\n  \"properties\": {\r\n    \"files\": [\r\n      {\r\n        \"uri\": \"5.png\",\r\n        \"type\": \"image\/png\"\r\n      }\r\n    ],\r\n    \"category\": \"image\",\r\n    \"creators\": []\r\n  },\r\n  \"compiler\": \"NFTexport.io\"\r\n}\r\n<\/pre>\n<p>The &#8220;attributes&#8221; array, need to be converted to<\/p>\n<pre>attributes[Background], attributes[Luckbox]\r\nDOT-6, 3\r\n<\/pre>\n<p>I used <a href=\"https:\/\/www.withdata.com\/data-file-converter\/\" target=\"_blank\" rel=\"noopener\">Data File Converter<\/a>, figured out to converting these JSON file to CSV, in a minutes.<\/p>\n<p>1. Open JSON file in DataFileConverter, set JSON options.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/case\/json_attributes.png\" alt=\"Convert JSON with attributes to CSV - open JSON\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" \/><\/p>\n<p>2. Set JSON custom columns.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/case\/json_attributes_custom_columns.png\" alt=\"Convert JSON with attributes to CSV - set custom columns\" width=\"602\" height=\"465\" style=\"max-width:100%;height:auto;display:block;\" \/><\/p>\n<p>3. Set CSV options.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/case\/json_attributes_csv.png\" alt=\"Convert JSON with attributes to CSV - set CSV options\" width=\"722\" height=\"572\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p>4.&#8221;Next&#8221; and &#8220;Next&#8221;, convert, get the output CSV file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to\u00a0convert some NFT metadata JSON files to CSV for opensea. JSON data like this: { &#8220;name&#8221;: &#8220;5&#8221;, &#8220;description&#8221;: &#8220;&#8221;, &#8220;external_url&#8221;: &#8220;&#8221;, &#8220;image&#8221;: &#8220;5.png&#8221;, &#8220;attributes&#8221;: [ { &#8220;trait_type&#8221;: &#8220;Background&#8221;, &#8220;value&#8221;: &#8220;DOT-6&#8221; }, { &#8220;trait_type&#8221;: &#8220;Luckbox&#8221;, &#8220;value&#8221;: &#8220;3&#8221; } ], &#8220;properties&#8221;: { &#8220;files&#8221;: [ { &#8220;uri&#8221;: &#8220;5.png&#8221;, &#8220;type&#8221;: &#8220;image\/png&#8221; } ], &#8220;category&#8221;: &#8220;image&#8221;, &#8220;creators&#8221;: [] [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3141],"tags":[34,1418,1498],"class_list":["post-22488","post","type-post","status-publish","format-standard","hentry","category-use","tag-csv","tag-json","tag-json-to-csv"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/22488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=22488"}],"version-history":[{"count":1,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/22488\/revisions"}],"predecessor-version":[{"id":22489,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/22488\/revisions\/22489"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=22488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=22488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=22488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}