title: POSTing JSON body causes Rack::QueryParser::InvalidParameterError
body: <p>I'm simply trying to POST a JSON content-type http request from one Rails server to another.  Putting a <code>%</code> character in a value string in the JSON is causing the <code>Rack::QueryParser::InvalidParameterError</code> on the receiving server.</p>
  
  <p>On Server A, I use the httparty gem to perform a POST request w/ a JSON body</p>
  
  <pre><code>obj = {"key":"&lt;%= @results %&gt;"}
  resp = HTTParty.post('https://test-url.com/data',
  :body =&gt; obj.to_json,
  :options =&gt; { :headers =&gt; { 'Content-Type' =&gt; 'application/json', 'Accept' =&gt; 'application/json' } })
  </code></pre>
  
  <p>On Server B, I just parse the JSON from the request body</p>
  
  <pre><code>req_body = request.body.read()
  req_body_json = JSON.parse req_body
  # do work with json
  </code></pre>
  
  <p>This process works fine unless the <code>obj = {"key":"&lt;%= @results %&gt;"}</code> contains <code>%</code> chars, in which case this occurs on server B:</p>
  
  <pre><code>Started POST "/data" for 10.244.1.3 at 2018-01-02 19:27:04 +0000
  F, [2018-01-02T19:27:04.245275 #1] FATAL -- :
  F, [2018-01-02T19:27:04.245331 #1] FATAL -- : Rack::QueryParser::InvalidParameterError (invalid %-encoding ({"key":"\u003c%)):
  F, [2018-01-02T19:27:04.245358 #1] FATAL -- :
  F, [2018-01-02T19:27:04.245397 #1] FATAL -- : rack (2.0.3) lib/rack/query_parser.rb:72:in `rescue in parse_nested_query'
  rack (2.0.3) lib/rack/query_parser.rb:60:in `parse_nested_query'
  rack (2.0.3) lib/rack/request.rb:468:in `parse_query'
  rack (2.0.3) lib/rack/request.rb:343:in `POST'
  actionpack (5.1.4) lib/action_dispatch/http/request.rb:362:in `block (2 levels) in POST'
  actionpack (5.1.4) lib/action_dispatch/http/parameters.rb:107:in `block in parse_formatted_parameters'
  actionpack (5.1.4) lib/action_dispatch/http/parameters.rb:107:in `fetch'
  actionpack (5.1.4) lib/action_dispatch/http/parameters.rb:107:in `parse_formatted_parameters'
  actionpack (5.1.4) lib/action_dispatch/http/request.rb:361:in `block in POST'
  rack (2.0.3) lib/rack/request.rb:57:in `fetch'
  rack (2.0.3) lib/rack/request.rb:57:in `fetch_header'
  actionpack (5.1.4) lib/action_dispatch/http/request.rb:360:in `POST'
  ...
  </code></pre>
  
  <p>When I change <code>obj = {"key":"&lt;%= @results %&gt;"}</code> to <code>obj = {"key":"&lt;= @results&gt;"}</code> the exception does not occur.</p>
  
  <p>As far I know <code>%</code> is a valid in JSON, what am I missing here?</p>