1

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

Paul
  • 245
  • 3
  • 14
  • You would need a programming language to do the decoding, but I think you are just looking for a program to do it. If you are using a language, please specify which one. – James Black Nov 14 '09 at 22:36

4 Answers4

1

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
Jim Zajkowski
  • 987
  • 1
  • 7
  • 13
  • Jim, thanks for the fast, focused response. I'd carelessly assumed JSON since that's what the todoist API returns. Do you know if there's an easy-setup Ruby environment I could install on Windows to try this? – Paul Nov 14 '09 at 22:51
  • You can get the one-click ruby installer http://rubyforge.org/frs/?group_id=167&release_id=28426, both net/http and rexml are in the included standard library. – Jim Zajkowski Nov 15 '09 at 00:18
  • Sweet! It works (once I tried SciTE instead of fxri), and I got it writing to a text file. Thanks again. – Paul Nov 17 '09 at 03:21
1

there's a good discussion of how to do this with Python at How can I convert JSON to CSV?

Community
  • 1
  • 1
Amanda
  • 12,099
  • 17
  • 63
  • 91
0

Can you JSON decode it to an array and just iterate the array for values? A sample of the JSON output would be helpful.

Myles
  • 20,860
  • 4
  • 28
  • 37
0

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.

Jamison Dance
  • 19,896
  • 25
  • 97
  • 99