Skip to content

Commit

Permalink
use Oj instead of JSON to generate and parse json string
Browse files Browse the repository at this point in the history
  • Loading branch information
senid231 committed Dec 13, 2015
1 parent 2946354 commit 78396e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions jrpc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'netstring'
spec.add_dependency 'net_tcp_client', '>= 1.0.2'
spec.add_dependency 'oj'

spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down
6 changes: 3 additions & 3 deletions lib/jrpc/base_client.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'json'
require 'oj'
require 'forwardable'
module JRPC
class BaseClient
Expand All @@ -22,8 +22,8 @@ def invoke_request(method, *params)
id = generate_id
request['id'] = id

response = send_command JSON.generate(request)
response = JSON.parse response
response = send_command Oj.dump(request)
response = Oj.load(response)

validate_response(response, id)
parse_error(response['error']) if response.has_key?('error')
Expand Down
1 change: 1 addition & 0 deletions spec/tcp_client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'
require 'logger'
require 'json'

describe JRPC::TcpClient do

Expand Down

0 comments on commit 78396e3

Please sign in to comment.