Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sinatra server:
- require 'sinatra'
- require 'slim'
- require 'json'
- post '/json_mposition/?' do
- mobilePosition = params[:mposition].to_json
- for_json = JSON.parse(mobilePosition)
- end
- ------------------------------------------
- the html file
- <head>
- </head>
- <body>
- <form action="http://localhost:4567/json_mposition" method="post">
- <input type="text" name="mposition">
- <input type="submit" name="submit" value="invia">
- </form>
- </body>
- ---------------------------------------
- the json I pass:
- "{\"mobilePosition\":{\"user\":\"uuid\",\"password\":67,\"lat\":36.23232,\"long\":36.23232,\"altitude\":120.23232,\"acc uracy\":5}}"
- ----------------------------------------------
- what I get
- JSON::ParserError - 743: unexpected token at '"\\\"{\\\"mobilePosition\\\":{\\\"user\\\":\\\"uuid\\\",\\\"password\\\":67,\\\"lat\\\":36.23232,\\\"long\\\":36.23232,\\\"altitude\\\":120.23232,\\\"acc uracy\\\":5}}\\\" "':
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
- infomee.rb:49:in `block in <main>'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212:in `block in compile!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `[]'
- /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!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:788:in `route_eval'
- /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!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:821:in `block in process_route'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `catch'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `process_route'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:771:in `block in route!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `each'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `route!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:886:in `dispatch!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `block in call!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `block in invoke'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `catch'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `invoke'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `call!'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:692:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/path_traversal.rb:16:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/json_csrf.rb:17:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/base.rb:47:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/logger.rb:15:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/commonlogger.rb:20:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:21:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `block in call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1403:in `synchronize'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `call'
- /home/giuseppe/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
- /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
- /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
- /home/giuseppe/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
- localhost.localdomain - - [11/Dec/2011:19:48:02 CET] "POST /json_mposition HTTP/1.1" 500 114290
- - -> /json_mposition
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement