Advertisement
Guest User

Untitled

a guest
Dec 11th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. Sinatra server:
  2.  
  3. require 'sinatra'
  4. require 'slim'
  5. require 'json'
  6.  
  7.  
  8. post '/json_mposition/?' do
  9. mobilePosition = params[:mposition].to_json
  10. for_json = JSON.parse(mobilePosition)
  11. end
  12.  
  13. ------------------------------------------
  14. the html file
  15.  
  16. <head>
  17. </head>
  18. <body>
  19. <form action="http://localhost:4567/json_mposition" method="post">
  20. <input type="text" name="mposition">
  21. <input type="submit" name="submit" value="invia">
  22. </form>
  23. </body>
  24.  
  25.  
  26. ---------------------------------------
  27. the json I pass:
  28.  
  29. "{\"mobilePosition\":{\"user\":\"uuid\",\"password\":67,\"lat\":36.23232,\"long\":36.23232,\"altitude\":120.23232,\"acc uracy\":5}}"
  30.  
  31. ----------------------------------------------
  32. what I get
  33.  
  34.  
  35. JSON::ParserError - 743: unexpected token at '"\\\"{\\\"mobilePosition\\\":{\\\"user\\\":\\\"uuid\\\",\\\"password\\\":67,\\\"lat\\\":36.23232,\\\"long\\\":36.23232,\\\"altitude\\\":120.23232,\\\"acc uracy\\\":5}}\\\" "':
  36. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
  37. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
  38. infomee.rb:49:in `block in <main>'
  39. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `call'
  40. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `block in compile!'
  41. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `[]'
  42. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `block (3 levels) in route!'
  43. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:788:in `route_eval'
  44. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `block (2 levels) in route!'
  45. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:821:in `block in process_route'
  46. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `catch'
  47. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `process_route'
  48. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:771:in `block in route!'
  49. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `each'
  50. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `route!'
  51. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:886:in `dispatch!'
  52. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `block in call!'
  53. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `block in invoke'
  54. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `catch'
  55. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `invoke'
  56. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `call!'
  57. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:692:in `call'
  58. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
  59. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/path_traversal.rb:16:in `call'
  60. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/json_csrf.rb:17:in `call'
  61. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/base.rb:47:in `call'
  62. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
  63. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/logger.rb:15:in `call'
  64. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/commonlogger.rb:20:in `call'
  65. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
  66. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
  67. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:21:in `call'
  68. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `block in call'
  69. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1403:in `synchronize'
  70. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `call'
  71. /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
  72. /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
  73. /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
  74. /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
  75. localhost.localdomain - - [11/Dec/2011:19:48:02 CET] "POST /json_mposition HTTP/1.1" 500 114290
  76. - -> /json_mposition
  77.  
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement