oj 2.12.3 → 2.12.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/oj/fast.c +1 -0
- data/ext/oj/saj.c +2 -2
- data/lib/oj/saj.rb +4 -4
- data/lib/oj/version.rb +1 -1
- data/test/bug_fast.rb +32 -0
- data/test/bug_load.rb +24 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a014def903ab0e1994fd5c35f882bbfc4d19b4
|
4
|
+
data.tar.gz: b02d7ad3224f234b26c3a53039c4f802fc362427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48e74d74f16124fe1a3db9111071886cbcdb2f92714b75a73534125a6c6ae79697d419a31e99a7aa0546a53075e90c83f4d1ee99ebf979c14667f66375c1125
|
7
|
+
data.tar.gz: b8ec4119322934662c75def9c6951b1d27ee10dc9872fa9214f6e511afe4e3e47adc9cd4cde3b7a3addfeaee6cd786f4474c92042c5fe267ff514ebb0c3adba2
|
data/README.md
CHANGED
@@ -26,9 +26,9 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
|
|
26
26
|
|
27
27
|
[![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
|
28
28
|
|
29
|
-
##
|
29
|
+
## Current Release 2.12.4
|
30
30
|
|
31
|
-
- Fixed
|
31
|
+
- Fixed memory leak in Oj::Doc when not using a given proc.
|
32
32
|
|
33
33
|
[Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
|
34
34
|
|
data/ext/oj/fast.c
CHANGED
data/ext/oj/saj.c
CHANGED
@@ -69,9 +69,9 @@ static void next_non_white(ParseInfo pi);
|
|
69
69
|
static char* read_quoted_value(ParseInfo pi);
|
70
70
|
static void skip_comment(ParseInfo pi);
|
71
71
|
|
72
|
-
/* This
|
72
|
+
/* This JSON parser is a single pass, destructive, callback parser. It is a
|
73
73
|
* single pass parse since it only make one pass over the characters in the
|
74
|
-
*
|
74
|
+
* JSON document string. It is destructive because it re-uses the content of
|
75
75
|
* the string for values in the callback and places \0 characters at various
|
76
76
|
* places to mark the end of tokens and strings. It is a callback parser like
|
77
77
|
* a SAX parser because it uses callback when document elements are
|
data/lib/oj/saj.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Oj
|
2
2
|
# A SAX style parse handler for JSON hence the acronym SAJ for Simple API for
|
3
|
-
# JSON. The Oj::Saj handler class should be subclassed and then used with
|
4
|
-
#
|
5
|
-
#
|
3
|
+
# JSON. The Oj::Saj handler class should be subclassed and then used with the
|
4
|
+
# Oj::Saj key_parse() method. The Saj methods will then be called as the file
|
5
|
+
# is parsed.
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
#
|
@@ -19,7 +19,7 @@ module Oj
|
|
19
19
|
# end
|
20
20
|
#
|
21
21
|
# cnt = MySaj.new()
|
22
|
-
# File.open('any.
|
22
|
+
# File.open('any.json', 'r') do |f|
|
23
23
|
# Oj.saj_parse(cnt, f)
|
24
24
|
# end
|
25
25
|
#
|
data/lib/oj/version.rb
CHANGED
data/test/bug_fast.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
%w(lib ext test).each do |dir|
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'oj'
|
9
|
+
|
10
|
+
def create_item(doc)
|
11
|
+
#puts "#{doc.fetch('/id')}: #{doc.fetch('/labels/it/value')} - #{doc.fetch('/descriptions/it/value')}"
|
12
|
+
doc.fetch('/id')
|
13
|
+
doc.fetch('/labels/it/value')
|
14
|
+
doc.fetch('/descriptions/it/value')
|
15
|
+
end
|
16
|
+
|
17
|
+
100.times { |i|
|
18
|
+
File.open('dump_10k.json') { |f|
|
19
|
+
f.each { |line|
|
20
|
+
#Oj::Doc.open(line) { |doc|
|
21
|
+
doc = Oj::Doc.open(line)
|
22
|
+
begin
|
23
|
+
create_item(doc) if doc.fetch('/type') == 'item'
|
24
|
+
rescue Exception => e
|
25
|
+
puts "*** #{e.class}: #{e.message}"
|
26
|
+
end
|
27
|
+
doc.close
|
28
|
+
#}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
puts i
|
32
|
+
}
|
data/test/bug_load.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
%w(lib ext test).each do |dir|
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'oj'
|
9
|
+
|
10
|
+
def create_item(doc)
|
11
|
+
item_id = doc['source']
|
12
|
+
# ...
|
13
|
+
puts item_id
|
14
|
+
end
|
15
|
+
|
16
|
+
File.open('log.json') { |f|
|
17
|
+
Oj::load(f, mode: :compat) { |doc|
|
18
|
+
begin
|
19
|
+
create_item(doc) if doc['msgType'] == 1
|
20
|
+
rescue Exception => e
|
21
|
+
puts "*** #{e.class}: #{e.message}"
|
22
|
+
end
|
23
|
+
}
|
24
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.12.
|
4
|
+
version: 2.12.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -108,6 +108,8 @@ files:
|
|
108
108
|
- test/bug.rb
|
109
109
|
- test/bug2.rb
|
110
110
|
- test/bug3.rb
|
111
|
+
- test/bug_fast.rb
|
112
|
+
- test/bug_load.rb
|
111
113
|
- test/example.rb
|
112
114
|
- test/files.rb
|
113
115
|
- test/helper.rb
|