Guest User

Untitled

a guest
Feb 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. require 'rubygems'
  2. require 'json'
  3. require 'yaml'
  4.  
  5. j1 = <<JSON
  6. {
  7. "items": [
  8. {
  9. "foo": ["bar", "baz"]
  10. }
  11. ]
  12. }
  13. JSON
  14.  
  15. puts "JSON to be parsed:", j1
  16.  
  17. puts "JSON.parse:", JSON.parse(j1).inspect
  18.  
  19. puts "YAML.parse:", YAML.parse(j1).inspect
  20.  
  21. puts "\n\n"
  22.  
  23. j2 = <<JSON
  24. {
  25. "items": [
  26. {
  27. "foo": ["bar","baz"]
  28. }
  29. ]
  30. }
  31. JSON
  32.  
  33. puts "JSON to be parsed (NOTICE THE MISSING SPACE IN [\"bar\",\"baz\"]):", j2
  34.  
  35. puts "JSON.parse:", JSON.parse(j2).inspect
  36.  
  37. puts "YAML.parse:", YAML.parse(j2).inspect
Add Comment
Please, Sign In to add comment