fjson 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/spec_helper")
5
+ require File.expand_path("#{dir}/../lib/fjson")
6
+
7
+ context "String when not supporting unicode and KCODE is not UTF8 json" do
8
+ setup do
9
+ JSON.support_unicode = true
10
+ $KCODE = ""
11
+ end
12
+
13
+ specify "should let high values pass through when " +
14
+ "not supporting unicode and KCODE is not UTF8" do
15
+ val = [0xcf].pack("U")
16
+ JSON.utf8_to_json(val).should_equal "\303\217"
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/spec_helper")
5
+ require File.expand_path("#{dir}/../lib/fjson")
6
+
7
+ context "String when supporting unicode and KCODE is not utf8 json" do
8
+ setup do
9
+ JSON.support_unicode = true
10
+ $KCODE = ""
11
+ end
12
+
13
+ specify "should let high values pass through when " +
14
+ "supporting unicode and KCODE is not UTF8" do
15
+ val = [0xcf].pack("U")
16
+ JSON.utf8_to_json(val).should_equal "\303\217"
17
+ end
18
+ end
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/spec_helper")
5
+ require File.expand_path("#{dir}/../lib/fjson")
6
+
7
+ context "String with latin1 character set Json" do
8
+ specify 'should format \b' do
9
+ utf_8_val = [?\b].pack("U")
10
+ JSON.utf8_to_json(utf_8_val).should_equal '\b'
11
+ end
12
+
13
+ specify 'should format \t' do
14
+ utf_8_val = [?\t].pack("U")
15
+ JSON.utf8_to_json(utf_8_val).should_equal '\t'
16
+ end
17
+
18
+ specify 'should format \n' do
19
+ utf_8_val = [?\n].pack("U")
20
+ JSON.utf8_to_json(utf_8_val).should_equal '\n'
21
+ end
22
+
23
+ specify 'should format \f' do
24
+ utf_8_val = [?\f].pack("U")
25
+ JSON.utf8_to_json(utf_8_val).should_equal '\f'
26
+ end
27
+
28
+ specify 'should format \r' do
29
+ utf_8_val = [?\r].pack("U")
30
+ JSON.utf8_to_json(utf_8_val).should_equal '\r'
31
+ end
32
+
33
+ specify 'should format ?"' do
34
+ utf_8_val = [?"].pack("U")
35
+ JSON.utf8_to_json(utf_8_val).should_equal '\"'
36
+ end
37
+
38
+ specify 'should format ?\\' do
39
+ utf_8_val = [?\\].pack("U")
40
+ JSON.utf8_to_json(utf_8_val).should_equal '\\\\'
41
+ end
42
+
43
+ specify "should format values between 0x00 and 0x1f" do
44
+ utf_8_val = [0x0f].pack("U")
45
+ JSON.utf8_to_json(utf_8_val).should_equal '\\u000f'
46
+ utf_8_val = [0x1e].pack("U")
47
+ JSON.utf8_to_json(utf_8_val).should_equal '\\u001e'
48
+ end
49
+
50
+ specify "should let ordinary text pass through" do
51
+ JSON.utf8_to_json("test").should_equal "test"
52
+ JSON.utf8_to_json('1').should_equal '1'
53
+ end
54
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/spec_helper")
5
+ require File.expand_path("#{dir}/../lib/fjson")
6
+
7
+ #context "String with UTF8 values when supporting unicode Json" do
8
+ # setup do
9
+ # JSON.support_unicode = true
10
+ # $KCODE = "UTF8"
11
+ # end
12
+ #
13
+ # specify "should format values between 0x00000080 and 0x000007ff" do
14
+ # val = [0x0080].pack("U")
15
+ # JSON.utf8_to_json(val).should_equal "\\u0080"
16
+ #
17
+ # val = [0x07ff].pack("U")
18
+ # JSON.utf8_to_json(val).should_equal "\\u07ff"
19
+ # end
20
+ #
21
+ # specify "should format values between 0x00001000 and 0x0000ffff" do
22
+ # val = [0x1000].pack("U")
23
+ # JSON.utf8_to_json(val).should_equal "\\u1000"
24
+ #
25
+ # val = [0xffff].pack("U")
26
+ # JSON.utf8_to_json(val).should_equal "\\uffff"
27
+ # end
28
+ #
29
+ # specify "should format values between 0x00010000 and 0x0010ffff" do
30
+ # val = [0x010000].pack("U")
31
+ # JSON.utf8_to_json(val).should_equal "\\ud800dc00"
32
+ #
33
+ # val = [0x10ffff].pack("U")
34
+ # JSON.utf8_to_json(val).should_equal "\\udbffdfff"
35
+ # end
36
+ #end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/spec_helper")
5
+ require File.expand_path("#{dir}/../lib/fjson")
6
+
7
+ context "A true object" do
8
+ specify "should convert to json" do
9
+ true.to_json.should_equal "true"
10
+ end
11
+
12
+ specify "to_json should accept any number of arguments" do
13
+ true.to_json(1, 2)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: fjson
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2006-10-10 00:00:00 -07:00
8
+ summary: This library is for parsing JSON strings and unparsing ruby data structures. This library is a fork of Florian Frank's JSON library with key parts implemented in C for performance improvements.
9
+ require_paths:
10
+ - lib
11
+ email: brian.takita@gmail.com
12
+ homepage: http://fjson.rubyforge.org
13
+ rubyforge_project: fjson
14
+ description: This library is for parsing JSON strings and unparsing ruby data structures. This library is a fork of Florian Frank's JSON library with key parts implemented in C for performance improvements.
15
+ autorequire: fjson
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Brian Takita
31
+ files:
32
+ - Rakefile
33
+ - GPL
34
+ - VERSION
35
+ - TODO
36
+ - CHANGES
37
+ - README
38
+ - lib/parser.rb
39
+ - lib/fjson.rb
40
+ - lib/extensions/kernel.rb
41
+ - lib/extensions/class.rb
42
+ - lib/extensions/string.rb
43
+ - lib/json/editor.rb
44
+ - lib/json_ext.so
45
+ - lib/state_ext.so
46
+ - lib/extensions/object_ext.so
47
+ - lib/extensions/integer_ext.so
48
+ - lib/extensions/float_ext.so
49
+ - lib/extensions/string_ext.so
50
+ - lib/extensions/true_class_ext.so
51
+ - lib/extensions/false_class_ext.so
52
+ - lib/extensions/nil_class_ext.so
53
+ - lib/extensions/array_ext.so
54
+ - lib/extensions/hash_ext.so
55
+ - spec/true_class_spec.rb
56
+ - spec/float_spec.rb
57
+ - spec/string_spec.rb
58
+ - spec/object_spec.rb
59
+ - spec/nil_class_spec.rb
60
+ - spec/array_spec.rb
61
+ - spec/spec_helper.rb
62
+ - spec/false_class_spec.rb
63
+ - spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
64
+ - spec/state_spec.rb
65
+ - spec/hash_spec.rb
66
+ - spec/spec_suite.rb
67
+ - spec/integer_spec.rb
68
+ - spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
69
+ - spec/string_with_latin1_character_set_json_spec.rb
70
+ - spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
71
+ test_files:
72
+ - spec/true_class_spec.rb
73
+ - spec/float_spec.rb
74
+ - spec/string_spec.rb
75
+ - spec/object_spec.rb
76
+ - spec/nil_class_spec.rb
77
+ - spec/array_spec.rb
78
+ - spec/false_class_spec.rb
79
+ - spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
80
+ - spec/state_spec.rb
81
+ - spec/hash_spec.rb
82
+ - spec/integer_spec.rb
83
+ - spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
84
+ - spec/string_with_latin1_character_set_json_spec.rb
85
+ - spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
86
+ rdoc_options: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ executables: []
91
+
92
+ extensions: []
93
+
94
+ requirements: []
95
+
96
+ dependencies: []
97
+