Reputation: 245
How might you take JSON output (e.g., from http://www.kinggary.com/tools/todoist-export.php) and strip the names to yield just the values from each pair, as CSV or human-friendly text? Want a more readable, human-editable backup of my friend's data on todoist.com
Upvotes: 1
Views: 6698
Reputation: 12747
there's a good discussion of how to do this with Python at How can I convert JSON to CSV?
Upvotes: 1
Reputation: 20184
What language? PHP has a json_decode()
function that turns the JSON into an object or associative array. You could then loop through the array or get the values from the object to turn it into whatever format you like.
Upvotes: 0
Reputation: 987
Your example site generates XML for me, not JSON. In either case I'd probably reach for Ruby:
require 'net/http'
require 'rexml/document'
xml = Net::HTTP.get_response(URI.parse("http://www.kinggary.com/tools/todoist-export.php?completed=incomplete&retrieval=view&submit=Submit&process=true&key=MYKEY")).body
data = REXML::Document.new(xml)
data.elements.each('//task/content') do |e|
puts e.text
end
Upvotes: 1
Reputation: 21510
Can you JSON decode it to an array and just iterate the array for values? A sample of the JSON output would be helpful.
Upvotes: 0