fizx-ordered_json 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +29 -0
  2. data/CHANGELOG +22 -0
  3. data/README +4 -0
  4. data/Rakefile +35 -0
  5. data/ext/Makefile +149 -0
  6. data/ext/json-c-0.8/AUTHORS +2 -0
  7. data/ext/json-c-0.8/COPYING +19 -0
  8. data/ext/json-c-0.8/ChangeLog +73 -0
  9. data/ext/json-c-0.8/INSTALL +229 -0
  10. data/ext/json-c-0.8/Makefile.am +43 -0
  11. data/ext/json-c-0.8/Makefile.in +734 -0
  12. data/ext/json-c-0.8/NEWS +1 -0
  13. data/ext/json-c-0.8/README +20 -0
  14. data/ext/json-c-0.8/aclocal.m4 +8794 -0
  15. data/ext/json-c-0.8/arraylist.c +93 -0
  16. data/ext/json-c-0.8/arraylist.h +45 -0
  17. data/ext/json-c-0.8/bits.h +27 -0
  18. data/ext/json-c-0.8/config.guess +1526 -0
  19. data/ext/json-c-0.8/config.h.in +121 -0
  20. data/ext/json-c-0.8/config.sub +1658 -0
  21. data/ext/json-c-0.8/configure +14243 -0
  22. data/ext/json-c-0.8/configure.in +33 -0
  23. data/ext/json-c-0.8/debug.c +98 -0
  24. data/ext/json-c-0.8/debug.h +42 -0
  25. data/ext/json-c-0.8/depcomp +530 -0
  26. data/ext/json-c-0.8/doc/html/annotated.html +40 -0
  27. data/ext/json-c-0.8/doc/html/arraylist_8h.html +234 -0
  28. data/ext/json-c-0.8/doc/html/bits_8h.html +144 -0
  29. data/ext/json-c-0.8/doc/html/config_8h.html +606 -0
  30. data/ext/json-c-0.8/doc/html/debug_8h.html +386 -0
  31. data/ext/json-c-0.8/doc/html/doxygen.css +473 -0
  32. data/ext/json-c-0.8/doc/html/doxygen.png +0 -0
  33. data/ext/json-c-0.8/doc/html/files.html +42 -0
  34. data/ext/json-c-0.8/doc/html/functions.html +206 -0
  35. data/ext/json-c-0.8/doc/html/functions_vars.html +206 -0
  36. data/ext/json-c-0.8/doc/html/globals.html +445 -0
  37. data/ext/json-c-0.8/doc/html/globals_defs.html +200 -0
  38. data/ext/json-c-0.8/doc/html/globals_enum.html +50 -0
  39. data/ext/json-c-0.8/doc/html/globals_eval.html +135 -0
  40. data/ext/json-c-0.8/doc/html/globals_func.html +194 -0
  41. data/ext/json-c-0.8/doc/html/globals_type.html +58 -0
  42. data/ext/json-c-0.8/doc/html/globals_vars.html +50 -0
  43. data/ext/json-c-0.8/doc/html/index.html +25 -0
  44. data/ext/json-c-0.8/doc/html/json_8h.html +26 -0
  45. data/ext/json-c-0.8/doc/html/json__object_8h.html +1042 -0
  46. data/ext/json-c-0.8/doc/html/json__object__private_8h.html +69 -0
  47. data/ext/json-c-0.8/doc/html/json__tokener_8h.html +360 -0
  48. data/ext/json-c-0.8/doc/html/json__util_8h.html +100 -0
  49. data/ext/json-c-0.8/doc/html/linkhash_8h.html +734 -0
  50. data/ext/json-c-0.8/doc/html/printbuf_8h.html +171 -0
  51. data/ext/json-c-0.8/doc/html/structarray__list.html +104 -0
  52. data/ext/json-c-0.8/doc/html/structjson__object.html +141 -0
  53. data/ext/json-c-0.8/doc/html/structjson__object__iter.html +87 -0
  54. data/ext/json-c-0.8/doc/html/structjson__tokener.html +206 -0
  55. data/ext/json-c-0.8/doc/html/structjson__tokener__srec.html +104 -0
  56. data/ext/json-c-0.8/doc/html/structlh__entry.html +105 -0
  57. data/ext/json-c-0.8/doc/html/structlh__table.html +275 -0
  58. data/ext/json-c-0.8/doc/html/structprintbuf.html +87 -0
  59. data/ext/json-c-0.8/doc/html/tab_b.gif +0 -0
  60. data/ext/json-c-0.8/doc/html/tab_l.gif +0 -0
  61. data/ext/json-c-0.8/doc/html/tab_r.gif +0 -0
  62. data/ext/json-c-0.8/doc/html/tabs.css +102 -0
  63. data/ext/json-c-0.8/doc/html/unionjson__object_1_1data.html +140 -0
  64. data/ext/json-c-0.8/install-sh +519 -0
  65. data/ext/json-c-0.8/json.h +31 -0
  66. data/ext/json-c-0.8/json.pc.in +11 -0
  67. data/ext/json-c-0.8/json_object.c +511 -0
  68. data/ext/json-c-0.8/json_object.h +310 -0
  69. data/ext/json-c-0.8/json_object_private.h +44 -0
  70. data/ext/json-c-0.8/json_tokener.c +517 -0
  71. data/ext/json-c-0.8/json_tokener.h +90 -0
  72. data/ext/json-c-0.8/json_util.c +122 -0
  73. data/ext/json-c-0.8/json_util.h +23 -0
  74. data/ext/json-c-0.8/linkhash.c +218 -0
  75. data/ext/json-c-0.8/linkhash.h +264 -0
  76. data/ext/json-c-0.8/ltmain.sh +7880 -0
  77. data/ext/json-c-0.8/missing +360 -0
  78. data/ext/json-c-0.8/printbuf.c +145 -0
  79. data/ext/json-c-0.8/printbuf.h +38 -0
  80. data/ext/json-c-0.8/test1.c +164 -0
  81. data/ext/json-c-0.8/test2.c +20 -0
  82. data/ext/json-c-0.8/test3.c +22 -0
  83. data/ext/ordered_json_c.c +199 -0
  84. data/lib/ordered_json.rb +26 -0
  85. data/ordered_json.gemspec +102 -0
  86. data/test/crashing_example.rb +1 -0
  87. data/test/ordered_json_test.rb +86 -0
  88. data/test/pretty.json +11 -0
  89. metadata +91 -50
@@ -0,0 +1,20 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <stddef.h>
4
+ #include <string.h>
5
+
6
+ #include "json.h"
7
+
8
+
9
+ int main(int argc, char **argv)
10
+ {
11
+ struct json_object *new_obj;
12
+
13
+ MC_SET_DEBUG(1);
14
+
15
+ new_obj = json_tokener_parse("/* more difficult test case */ { \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": \"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }");
16
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
17
+ json_object_put(new_obj);
18
+
19
+ return 0;
20
+ }
@@ -0,0 +1,22 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ #include "json.h"
5
+
6
+ int
7
+ main()
8
+ {
9
+ struct json_object *jobj;
10
+ char *input = malloc(1024);
11
+
12
+ while (fgets(input, 1024, stdin) != NULL) {
13
+ jobj = json_tokener_parse(input);
14
+ if (is_error(jobj)) {
15
+ printf("error parsing json\n");
16
+ } else {
17
+ printf("%s\n", json_object_to_json_string(jobj));
18
+ json_object_put(jobj);
19
+ }
20
+ }
21
+ return 0;
22
+ }
@@ -0,0 +1,199 @@
1
+ #include "ruby.h"
2
+ #include "json-c-0.8/json.h"
3
+ #include "json-c-0.8/printbuf.h"
4
+ #include <stdio.h>
5
+ #include <stdbool.h>
6
+
7
+ VALUE oj_dump(VALUE, VALUE, VALUE);
8
+ struct json_object* oj_dump_json(VALUE obj);
9
+ struct json_object* oj_dump_json_hash(VALUE obj);
10
+ struct json_object* oj_dump_json_array(VALUE obj);
11
+
12
+ char* oj_pretty_dump(struct json_object* json, struct printbuf *buf, int depth);
13
+
14
+ VALUE oj_parse(VALUE, VALUE, VALUE);
15
+ VALUE oj_build(struct json_object *, VALUE);
16
+ VALUE oj_build_object(struct json_object *, VALUE);
17
+ VALUE oj_build_array(struct json_object *, VALUE);
18
+
19
+ VALUE rb_dump_error;
20
+ VALUE rb_parse_error;
21
+
22
+ void Init_ordered_json_c()
23
+ {
24
+ rb_dump_error = rb_eval_string("OrderedJSON::DumpError");
25
+ rb_parse_error = rb_eval_string("OrderedJSON::ParseError");
26
+ VALUE c_oj = rb_define_class("OrderedJSONC", rb_cObject);
27
+ rb_define_singleton_method(c_oj, "parse", oj_parse, 2);
28
+ rb_define_singleton_method(c_oj, "dump", oj_dump, 2);
29
+ }
30
+
31
+ VALUE oj_parse(VALUE self, VALUE str, VALUE hash_class){
32
+ VALUE out;
33
+ char *c_str = STR2CSTR(str);
34
+ struct json_object* json = json_tokener_parse(c_str);
35
+ if(is_error(json)) {
36
+ rb_raise(rb_parse_error, "Invalid JSON");
37
+ } else {
38
+ out = oj_build(json, hash_class);
39
+ }
40
+ json_object_put(json);
41
+ return out;
42
+ }
43
+
44
+ VALUE oj_dump(VALUE self, VALUE obj, VALUE pretty) {
45
+ struct json_object* json = oj_dump_json(obj);
46
+ struct printbuf *buf = printbuf_new();
47
+ char *cstr = (pretty != Qfalse && pretty != Qnil) ?
48
+ oj_pretty_dump(json, buf, 0) :
49
+ json_object_to_json_string(json);
50
+ VALUE out = rb_str_new2(cstr);
51
+ json_object_put(json);
52
+ printbuf_free(buf);
53
+ return out;
54
+ }
55
+
56
+ char* tabs(int num) {
57
+ char *tabs = malloc(num + 2);
58
+ *tabs = '\n';
59
+ for(int i = 0; i < num; i++){
60
+ *(tabs + i + 1) = '\t';
61
+ }
62
+ *(tabs + num + 1) = 0;
63
+ return tabs;
64
+ }
65
+
66
+ char* oj_pretty_dump(struct json_object* json, struct printbuf *buf, int depth) {
67
+ if(json != NULL) {
68
+ switch(json_object_get_type(json)){
69
+ case json_type_object:
70
+ oj_pretty_dump_object(json, buf, depth);
71
+ break;
72
+ case json_type_array:
73
+ oj_pretty_dump_array(json, buf, depth);
74
+ break;
75
+ default:
76
+ sprintbuf(buf, "%s", json_object_to_json_string(json));
77
+ }
78
+ } else {
79
+ sprintbuf(buf, "null");
80
+ }
81
+ return buf->buf;
82
+ }
83
+
84
+ void oj_pretty_dump_object(struct json_object* json, struct printbuf *buf, int depth) {
85
+ struct json_object *jtmp;
86
+ char *space = tabs(depth);
87
+ char *space1 = tabs(depth + 1);
88
+ char *comma = "";
89
+ sprintbuf(buf, "{");
90
+ json_object_object_foreach(json, key, val) {
91
+ jtmp = json_object_new_string(key);
92
+ sprintbuf(buf, "%s%s%s: ", comma, space1, json_object_to_json_string(jtmp));
93
+ json_object_put(jtmp);
94
+ oj_pretty_dump(val, buf, depth + 1);
95
+ comma = ",";
96
+ }
97
+ sprintbuf(buf, "%s}", space);
98
+ free(space);
99
+ free(space1);
100
+ }
101
+
102
+ void oj_pretty_dump_array(struct json_object* json, struct printbuf *buf, int depth) {
103
+ int len = json_object_array_length(json);
104
+ char *space = (len < 2) ? strdup("") : tabs(depth);
105
+ char *space1 = (len < 2) ? strdup("") : tabs(depth + 1);
106
+ sprintbuf(buf, "[ ");
107
+ for(int i = 0; i < len; i++) {
108
+ char *comma = i == 0 ? "" : ", ";
109
+ sprintbuf(buf, "%s%s", comma, space1);
110
+ oj_pretty_dump(json_object_array_get_idx(json, i), buf, depth + 1);
111
+ }
112
+ sprintbuf(buf, " %s]", space);
113
+ free(space);
114
+ }
115
+
116
+ struct json_object* oj_dump_json(VALUE obj) {
117
+ switch(TYPE(obj)) {
118
+ case T_OBJECT:
119
+ case T_HASH:
120
+ return oj_dump_json_hash(obj);
121
+ case T_FLOAT:
122
+ return json_object_new_double(NUM2DBL(obj));
123
+ case T_STRING:
124
+ return json_object_new_string(STR2CSTR(obj));
125
+ case T_ARRAY:
126
+ return oj_dump_json_array(obj);
127
+ case T_FIXNUM:
128
+ case T_BIGNUM:
129
+ return json_object_new_int(NUM2INT(obj));
130
+ case T_TRUE:
131
+ return json_object_new_boolean(1);
132
+ case T_FALSE:
133
+ return json_object_new_boolean(0);
134
+ case T_NIL:
135
+ default:
136
+ return NULL;
137
+ }
138
+ }
139
+
140
+ struct json_object* oj_dump_json_hash(VALUE hash) {
141
+ struct json_object *json = json_object_new_object();
142
+ VALUE keys = rb_funcall(hash, rb_intern("keys"), 0);
143
+ VALUE values = rb_funcall(hash, rb_intern("values"), 0);
144
+ int len = RARRAY(keys)->len;
145
+ for(int i = 0; i < len; i++) {
146
+ json_object_object_add(json,
147
+ STR2CSTR(rb_funcall(rb_ary_entry(keys, i), rb_intern("to_s"), 0)),
148
+ oj_dump_json(rb_ary_entry(values, i))
149
+ );
150
+ }
151
+ return json;
152
+ }
153
+
154
+ struct json_object* oj_dump_json_array(VALUE array) {
155
+ int len = RARRAY(array)->len;
156
+ struct json_object *json = json_object_new_array();;
157
+ for(int i = 0; i < len; i++) {
158
+ json_object_array_add(json, oj_dump_json(rb_ary_entry(array, i)));
159
+ }
160
+ return json;
161
+ }
162
+
163
+ VALUE oj_build(struct json_object* json, VALUE hash_class){
164
+ if(json != NULL) {
165
+ switch(json_object_get_type(json)){
166
+ case json_type_null:
167
+ return Qnil;
168
+ case json_type_boolean:
169
+ return json_object_get_boolean(json) ? Qtrue : Qfalse;
170
+ case json_type_double:
171
+ return rb_float_new(json_object_get_double(json));
172
+ case json_type_int:
173
+ return INT2FIX(json_object_get_int(json));
174
+ case json_type_object:
175
+ return oj_build_object(json, hash_class);
176
+ case json_type_array:
177
+ return oj_build_array(json, hash_class);
178
+ case json_type_string:
179
+ return rb_str_new2(json_object_get_string(json));
180
+ }
181
+ }
182
+ return Qnil;
183
+ }
184
+
185
+ VALUE oj_build_object(struct json_object * json, VALUE hash_class) {
186
+ VALUE hash = rb_funcall(hash_class, rb_intern("new"), 0);
187
+ json_object_object_foreach(json, key, value) {
188
+ rb_funcall(hash, rb_intern("[]="), 2, rb_str_new2(key), oj_build(value, hash_class));
189
+ }
190
+ return hash;
191
+ }
192
+
193
+ VALUE oj_build_array(struct json_object * json, VALUE hash_class) {
194
+ VALUE array = rb_ary_new();
195
+ for(int i = 0; i < json_object_array_length(json); i++) {
196
+ rb_ary_push(array, oj_build(json_object_array_get_idx(json, i), hash_class));
197
+ }
198
+ return array;
199
+ }
@@ -0,0 +1,26 @@
1
+ require "rubygems"
2
+ require 'collections/sequenced_hash'
3
+
4
+ class OrderedHash < SequencedHash; end
5
+
6
+ module OrderedJSON
7
+ class ParseError < RuntimeError; end
8
+ class DumpError < RuntimeError; end
9
+
10
+
11
+ def parse(str)
12
+ ::OrderedJSONC.parse(str, OrderedHash)
13
+ end
14
+
15
+ def dump(obj, pretty = false)
16
+ ::OrderedJSONC.dump(obj, pretty)
17
+ end
18
+
19
+ def pretty_dump(obj)
20
+ dump(obj, true)
21
+ end
22
+
23
+ extend self
24
+ end
25
+
26
+ require File.dirname(__FILE__) + "/../ext/ordered_json_c"
@@ -0,0 +1,102 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "ordered_json"
3
+ s.version = "0.3.2"
4
+ s.date = "2009-03-19"
5
+ s.summary = "Ordered json hash conversion "
6
+ s.email = "kyle@kylemaxwell.com"
7
+ s.has_rdoc = true
8
+ s.extensions = "ext/extconf.rb"
9
+ s.authors = ["Kyle Maxwell"]
10
+ s.files = %w[
11
+ .gitignore
12
+ CHANGELOG
13
+ ext/extconf.rb
14
+ ext/json-c-0.8/aclocal.m4
15
+ ext/json-c-0.8/arraylist.c
16
+ ext/json-c-0.8/arraylist.h
17
+ ext/json-c-0.8/AUTHORS
18
+ ext/json-c-0.8/bits.h
19
+ ext/json-c-0.8/ChangeLog
20
+ ext/json-c-0.8/config.guess
21
+ ext/json-c-0.8/config.h.in
22
+ ext/json-c-0.8/config.sub
23
+ ext/json-c-0.8/configure
24
+ ext/json-c-0.8/configure.in
25
+ ext/json-c-0.8/COPYING
26
+ ext/json-c-0.8/debug.c
27
+ ext/json-c-0.8/debug.h
28
+ ext/json-c-0.8/depcomp
29
+ ext/json-c-0.8/doc/html/annotated.html
30
+ ext/json-c-0.8/doc/html/arraylist_8h.html
31
+ ext/json-c-0.8/doc/html/bits_8h.html
32
+ ext/json-c-0.8/doc/html/config_8h.html
33
+ ext/json-c-0.8/doc/html/debug_8h.html
34
+ ext/json-c-0.8/doc/html/doxygen.css
35
+ ext/json-c-0.8/doc/html/doxygen.png
36
+ ext/json-c-0.8/doc/html/files.html
37
+ ext/json-c-0.8/doc/html/functions.html
38
+ ext/json-c-0.8/doc/html/functions_vars.html
39
+ ext/json-c-0.8/doc/html/globals.html
40
+ ext/json-c-0.8/doc/html/globals_defs.html
41
+ ext/json-c-0.8/doc/html/globals_enum.html
42
+ ext/json-c-0.8/doc/html/globals_eval.html
43
+ ext/json-c-0.8/doc/html/globals_func.html
44
+ ext/json-c-0.8/doc/html/globals_type.html
45
+ ext/json-c-0.8/doc/html/globals_vars.html
46
+ ext/json-c-0.8/doc/html/index.html
47
+ ext/json-c-0.8/doc/html/json_8h.html
48
+ ext/json-c-0.8/doc/html/json__object_8h.html
49
+ ext/json-c-0.8/doc/html/json__object__private_8h.html
50
+ ext/json-c-0.8/doc/html/json__tokener_8h.html
51
+ ext/json-c-0.8/doc/html/json__util_8h.html
52
+ ext/json-c-0.8/doc/html/linkhash_8h.html
53
+ ext/json-c-0.8/doc/html/printbuf_8h.html
54
+ ext/json-c-0.8/doc/html/structarray__list.html
55
+ ext/json-c-0.8/doc/html/structjson__object.html
56
+ ext/json-c-0.8/doc/html/structjson__object__iter.html
57
+ ext/json-c-0.8/doc/html/structjson__tokener.html
58
+ ext/json-c-0.8/doc/html/structjson__tokener__srec.html
59
+ ext/json-c-0.8/doc/html/structlh__entry.html
60
+ ext/json-c-0.8/doc/html/structlh__table.html
61
+ ext/json-c-0.8/doc/html/structprintbuf.html
62
+ ext/json-c-0.8/doc/html/tab_b.gif
63
+ ext/json-c-0.8/doc/html/tab_l.gif
64
+ ext/json-c-0.8/doc/html/tab_r.gif
65
+ ext/json-c-0.8/doc/html/tabs.css
66
+ ext/json-c-0.8/doc/html/unionjson__object_1_1data.html
67
+ ext/json-c-0.8/INSTALL
68
+ ext/json-c-0.8/install-sh
69
+ ext/json-c-0.8/json.h
70
+ ext/json-c-0.8/json.pc.in
71
+ ext/json-c-0.8/json_object.c
72
+ ext/json-c-0.8/json_object.h
73
+ ext/json-c-0.8/json_object_private.h
74
+ ext/json-c-0.8/json_tokener.c
75
+ ext/json-c-0.8/json_tokener.h
76
+ ext/json-c-0.8/json_util.c
77
+ ext/json-c-0.8/json_util.h
78
+ ext/json-c-0.8/linkhash.c
79
+ ext/json-c-0.8/linkhash.h
80
+ ext/json-c-0.8/ltmain.sh
81
+ ext/json-c-0.8/Makefile.am
82
+ ext/json-c-0.8/Makefile.in
83
+ ext/json-c-0.8/missing
84
+ ext/json-c-0.8/NEWS
85
+ ext/json-c-0.8/printbuf.c
86
+ ext/json-c-0.8/printbuf.h
87
+ ext/json-c-0.8/README
88
+ ext/json-c-0.8/test1.c
89
+ ext/json-c-0.8/test2.c
90
+ ext/json-c-0.8/test3.c
91
+ ext/Makefile
92
+ ext/ordered_json_c.c
93
+ lib/ordered_json.rb
94
+ ordered_json.gemspec
95
+ Rakefile
96
+ README
97
+ test/crashing_example.rb
98
+ test/ordered_json_test.rb
99
+ test/pretty.json
100
+ ]
101
+ s.add_dependency("collections", ["> 0.0.0"])
102
+ end
@@ -0,0 +1 @@
1
+ {"days"=>[{"day"=>"Today", "links"=>[{"title"=>"search freebies and free samples", "url"=>"/search.html"}, {"title"=>"link to freebie finder", "url"=>"/link.html"}, {"title"=>"friends of freebie finder", "url"=>"/links.html"}, {"title"=>"freebie tips", "url"=>"/tips.html"}, {"title"=>"freebies by email", "url"=>"http://www.feedblitz.com/f/?Sub=70455"}, {"title"=>"forum", "url"=>"http://forum.absurdlycool.com/"}, {"title"=>"freebies by RSS", "url"=>"/rss.html"}, {"title"=>"suggestions are always appreciated", "url"=>"/contact.cgi"}, {"title"=>"check out our new forum!", "url"=>"http://forum.absurdlycool.com"}, {"title"=>"Introducing Freebie Finder Forums!", "url"=>"http://forum.absurdlycool.com/"}, {"title"=>"uk", "url"=>"http://absurdlycool.com/UK/all-freebies"}, {"title"=>"canada", "url"=>"http://absurdlycool.com/CANADA/all-freebies"}, {"title"=>"usa", "url"=>"http://absurdlycool.com/USA/all-freebies"}, {"title"=>"Free Bread Breakthrough Recipe Book", "url"=>"http://www.breadbreakthrough.com/Default.aspx"}, {"title"=>"food", "url"=>"http://absurdlycool.com/all/food-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10442/free-bread-breakthrough-recipe-book"}, {"title"=>"success. To order today, click here No shipping and handling fees", "url"=>"http://www.breadbreakthrough.com/Redemption.aspx"}, {"title"=>"food", "url"=>"http://absurdlycool.com/all/food-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10443/success-to-order-today-click-here-no-shipping-and-handling-fees"}, {"title"=>"Miscellaneous :: Wildflower Guidebook and catalog", "url"=>"http://www.wildseedfarms.com/catalog.html"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10444/miscellaneous-wildflower-guidebook-and-catalog"}, {"title"=>"Segue to Solar--Free Solar Sticker or Message Magnet", "url"=>"http://www.seguetosolar.com/freesticker.html"}, {"title"=>"kids", "url"=>"http://absurdlycool.com/all/kids-freebies"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10445/segue-to-solar-free-solar-sticker-or-message-magnet"}, {"title"=>"Aerie Undies--Free Pair of Undies at Aerie Store ( 3/12 - 3/18", "url"=>"http://view.ed4.net/v/XHBORK/AY8T0/0G2OD8R/QEV01H/MAILACTION=1&FORMAT=H"}, {"title"=>"coupons", "url"=>"http://absurdlycool.com/all/coupons"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10441/aerie-undies-free-pair-of-undies-at-aerie-store-3-12-3-18"}, {"title"=>"Free 25 staples Gift Card for Teachers", "url"=>"http://www.staples.com/sbd/cre/marketing/schoolkidz/"}, {"title"=>"gifts", "url"=>"http://absurdlycool.com/all/gifts"}, {"title"=>"food", "url"=>"http://absurdlycool.com/all/food-freebies"}, {"title"=>"software", "url"=>"http://absurdlycool.com/all/software-freebies"}, {"title"=>"educational", "url"=>"http://absurdlycool.com/all/educational-freebies"}, {"title"=>"Fab Free", "url"=>"http://www.fabfree.com/"}, {"title"=>"Free Channel", "url"=>"http://www.freechannel.net/new.html"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10440/free-25-staples-gift-card-for-teachers"}]}, {"day"=>"Sat, 14 Mar 2009", "links"=>[{"title"=>"Free subscription to car and driver", "url"=>"http://www.freebizmag.com/emailcardriver04welcome.htm"}, {"title"=>"email", "url"=>"http://absurdlycool.com/all/email-freebies"}, {"title"=>"cars", "url"=>"http://absurdlycool.com/all/cars-freebies"}, {"title"=>"media", "url"=>"http://absurdlycool.com/all/media-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10436/free-subscription-to-car-and-driver"}, {"title"=>"Free tote from vix swimwear ", "url"=>"http://www.vixswimwear.com/vip-signup.asp"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Freebeez and Dealz", "url"=>"http://www.freebeezndealz.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10437/free-tote-from-vix-swimwear"}, {"title"=>"To get the Free Obesity Action Coalition posters, BMI charts, and", "url"=>"http://www.obesityaction.org/ordermaterials/overview.php"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"FreeGrabber", "url"=>"http://www.freegrabber.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10438/to-get-the-free-obesity-action-coalition-posters-bmi-charts-and"}, {"title"=>"Bra--Free Bra for Survey Participation - As Seen on Oprah", "url"=>"http://www.cybersurvey.com/surveys/Oprah/B01.htm"}, {"title"=>"clothing", "url"=>"http://absurdlycool.com/all/clothing-freebies"}, {"title"=>"Freebeez and Dealz", "url"=>"http://www.freebeezndealz.com/"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10439/bra-free-bra-for-survey-participation-as-seen-on-oprah"}, {"title"=>"Sign up here for a complimentary 2-issue to Redbook.", "url"=>"http://www.valuemags.com/freeoffer/freeoffer.asp?offer=Redbook_BBS"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreeSnatcher", "url"=>"http://www.freesnatcher.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10435/sign-up-here-for-a-complimentary-2-issue-to-redbook"}, {"title"=>"Free Brewmasters Tasting Kit From Killians Irish Red", "url"=>"http://georgekillians.com/"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreeStuff.com", "url"=>"http://freestuff.com"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10434/free-brewmasters-tasting-kit-from-killians-irish-red"}]}, {"day"=>"Fri, 13 Mar 2009", "links"=>[{"title"=>" Kodak Gallery - 20 FREE PRINTS for new Members", "url"=>"http://www.kodakgallery.com/Welcome.jsp"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10431/kodak-gallery-20-free-prints-for-new-members"}, {"title"=>"GoodNites--Free sample Pair of GoodNites Boxers for Boys", "url"=>"http://fsisolutions.com/kcgoodnitesboxers/"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"FreeGrabber", "url"=>"http://www.freegrabber.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10432/goodnites-free-sample-pair-of-goodnites-boxers-for-boys"}, {"title"=>"Free Bridal Invitations", "url"=>"http://www.annsbridalbargains.com/WE_SearchResults.cfm?prev=1&TempPrev=0&blnPreviewRequestSubmitted=0&recordsperpage=8&CompletedOrder=0&sBasketID=0&alogo=1&menu=none&morethanonepage=YES&HostDomain=0&FirstTimeThrough=1&option=WE_SearchResults.cfm&format=WedEnsVAa&vid=7597897CE2&CFID=70302588&CFTOKEN=38067380"}, {"title"=>"FreeSnatcher", "url"=>"http://www.freesnatcher.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10433/free-bridal-invitations"}, {"title"=>"Nicoderm CQ Sample ", "url"=>"http://lm.logicalmedia.com/z/8170/CD339/"}, {"title"=>"health", "url"=>"http://absurdlycool.com/all/health-freebies"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10430/nicoderm-cq-sample"}, {"title"=>"Get a Free Undie at Aerie Store", "url"=>"http://view.ed4.net/v/XHBORK/AY8T0/0G2OD8R/QEV01H/MAILACTION=1&FORMAT=H"}, {"title"=>"FreeSnatcher", "url"=>"http://www.freesnatcher.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10429/get-a-free-undie-at-aerie-store"}, {"title"=>"Free Campbells Tomato Seeds", "url"=>"http://www.helpgrowyoursoup.com/"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Yes All 4 Free", "url"=>"http://www.yesall4free.com/"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10426/free-campbells-tomato-seeds"}, {"title"=>"Free Eye Facts for Children Poster", "url"=>"http://catalog.nei.nih.gov/productcart/pc/viewPrd.asp?idcategory=21&idproduct=131#"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10427/free-eye-facts-for-children-poster"}, {"title"=>"Free 2009 Wildflower Reference Guide", "url"=>"http://www.wildseedfarms.com/index.html"}, {"title"=>"Fab Free", "url"=>"http://www.fabfree.com/"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10428/free-2009-wildflower-reference-guide"}]}, {"day"=>"Thu, 12 Mar 2009", "links"=>[{"title"=>"Free sample of ID personal lubricant", "url"=>"http://www.idlube.com/surveys/survey.php"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10424/free-sample-of-id-personal-lubricant"}, {"title"=>"Free Aveda shampoo", "url"=>"http://www.cedarhut.com/free_stuff_promo3.php"}, {"title"=>"beauty", "url"=>"http://absurdlycool.com/all/beauty-freebies"}, {"title"=>"Freebeez and Dealz", "url"=>"http://www.freebeezndealz.com/"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10425/free-aveda-shampoo"}, {"title"=>"Free Vegetarian Starter Kit", "url"=>"http://www.mercyforanimals.org/vegan-starter-kit.aspx"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10423/free-vegetarian-starter-kit"}, {"title"=>"Win prizes and possibly $5000 by joining the Ipsos i-Say Panel", "url"=>"http://lm.logicalmedia.com/z/6691/CD339/"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10422/win-prizes-and-possibly-5000-by-joining-the-ipsos-i-say-panel"}, {"title"=>"Try the new Arbys Roast Burger free w/ the purchase of a soft", "url"=>"http://www.arbys.com/arbyscoupon/?cid=bn_msn300x250030909"}, {"title"=>"Freebeez and Dealz", "url"=>"http://www.freebeezndealz.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10421/try-the-new-arbys-roast-burger-free-w-the-purchase-of-a-soft"}, {"title"=>"Free Shirt--Free T-Shirt from AudioVox for Uploaded Image", "url"=>"http://www.audiovoxconsumer.com/voxxconsumers/VoxxconsumersInfo.do?ACTION_TYPE_ID=ACTION_TYPE_EXISITING_CONTEST_DETAIL"}, {"title"=>"clothing", "url"=>"http://absurdlycool.com/all/clothing-freebies"}, {"title"=>"webmaster", "url"=>"http://absurdlycool.com/all/webmaster-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10420/free-shirt-free-t-shirt-from-audiovox-for-uploaded-image"}, {"title"=>"Free sample of Beyond Seven Condoms ", "url"=>"http://www.beyondsevencondoms.com/htmls/free_sample-eval.asp"}, {"title"=>"health", "url"=>"http://absurdlycool.com/all/health-freebies"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10418/free-sample-of-beyond-seven-condoms"}, {"title"=>"Free Song Download - Seven Mile Breakdown by Taylor Hicks", "url"=>"http://www.amazon.com/gp/product/B001U8T2WI?ie=UTF8&tag=awesdeal-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B001U8T2WI"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10419/free-song-download-seven-mile-breakdown-by-taylor-hicks"}]}, {"day"=>"Wed, 11 Mar 2009", "links"=>[{"title"=>"To get the Free sample bottle Aveda Black Malva Pure Plant shampoo", "url"=>"http://www.cedarhut.com/survey03_promo.php"}, {"title"=>"beauty", "url"=>"http://absurdlycool.com/all/beauty-freebies"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10417/to-get-the-free-sample-bottle-aveda-black-malva-pure-plant-shampoo"}, {"title"=>"Food :: Free Candy Pocket Tin Sample", "url"=>"http://billyboycandiesonline.com/ourcandy.html"}, {"title"=>"food", "url"=>"http://absurdlycool.com/all/food-freebies"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10415/food-free-candy-pocket-tin-sample"}, {"title"=>"Find the location nearest you to get your free sample of Fuji", "url"=>"http://www.sobeworld.com/index.php"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10411/find-the-location-nearest-you-to-get-your-free-sample-of-fuji"}, {"title"=>"Free 25 Chick Downtown Gift Card", "url"=>"http://chickdowntown.com/shopping_spree.asp"}, {"title"=>"gifts", "url"=>"http://absurdlycool.com/all/gifts"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10412/free-25-chick-downtown-gift-card"}, {"title"=>"Food :: Free Taco from Taco Del Mar", "url"=>"http://www.tacodelmar.com/tdm001_2009a/taxes_2009_choice.html"}, {"title"=>"food", "url"=>"http://absurdlycool.com/all/food-freebies"}, {"title"=>"coupons", "url"=>"http://absurdlycool.com/all/coupons"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10413/food-free-taco-from-taco-del-mar"}, {"title"=>"Kids :: Kidscope Comic and DVD", "url"=>"http://www.kidscope.org/individual_order.html"}, {"title"=>"kids", "url"=>"http://absurdlycool.com/all/kids-freebies"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10414/kids-kidscope-comic-and-dvd"}, {"title"=>"Free Tee Shirt From Bobs Garage", "url"=>"http://www.bobs-garage.com/"}, {"title"=>"clothing", "url"=>"http://absurdlycool.com/all/clothing-freebies"}, {"title"=>"Fab Free", "url"=>"http://www.fabfree.com/"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10410/free-tee-shirt-from-bobs-garage"}]}, {"day"=>"Tue, 10 Mar 2009", "links"=>[{"title"=>"Free Matrix Biolage sample ", "url"=>"http://www.matrix.com/advert/2009/01Rejuva/"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10407/free-matrix-biolage-sample"}, {"title"=>"To get your Free Volpi Italian meat product sample click on the", "url"=>"http://www.volpifoods.com/join-the-vip-club/"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"WeLoveFreeSamples", "url"=>"http://welovefreesamples.blogspot.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10409/to-get-your-free-volpi-italian-meat-product-sample-click-on-the"}, {"title"=>"Free Aveda Product Sample", "url"=>"http://downloads.self.com/self/pdfs/AvedaCoupon.pdf"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10405/free-aveda-product-sample"}, {"title"=>"Free Sample of Emergen-C Drink Mix", "url"=>"http://www.emergenc.com/bubbles/"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"FreeGrabber", "url"=>"http://www.freegrabber.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10406/free-sample-of-emergen-c-drink-mix"}, {"title"=>"Click here to request your free wedding catalog", "url"=>"http://www.gunthergifts.com/catalog-request-form.html"}, {"title"=>"Free Sample Direct", "url"=>"http://freesamplesdirect.com/blog/"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"Active Freebies", "url"=>"http://www.active-freebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10401/click-here-to-request-your-free-wedding-catalog"}, {"title"=>"Scrabble Compete against others for FREE or for cash prizes playing", "url"=>"http://1.ofsnetwork.com/z/37870/CD5726/&dp=0&l=0&subid1=&subid2=&subid3=&subid4=&subid5="}, {"title"=>"Sassysue", "url"=>"http://www.sassysue.com/new.htm"}, {"title"=>"FreakyFreddies", "url"=>"http://www.freakyfreddies.com/canadianfreebies.htm"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10402/scrabble-compete-against-others-for-free-or-for-cash-prizes-playing"}, {"title"=>"Health :: Free Sample of Kotex Ultra Thin Overnight with", "url"=>"http://startsampling.com/sm/100664/captureAddress.iphtml?item=100664"}, {"title"=>"samples", "url"=>"http://absurdlycool.com/all/samples"}, {"title"=>"health", "url"=>"http://absurdlycool.com/all/health-freebies"}, {"title"=>"FreebieWatch", "url"=>"http://www.freebiewatch.com/"}, {"title"=>"I Crave Freebies", "url"=>"http://www.icravefreebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10403/health-free-sample-of-kotex-ultra-thin-overnight-with"}, {"title"=>"Free E-Cards Online ", "url"=>"http://www.free-e-cards-online.com"}, {"title"=>"Free Channel", "url"=>"http://www.freechannel.net/new.html"}, {"title"=>"Active Freebies", "url"=>"http://www.active-freebies.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10400/free-e-cards-online"}, {"title"=>"Training Socks--Free 2-Pack of Training Socks at Lucy Stores", "url"=>"http://www.lucy.com/jump.jsp?itemID=1047&itemType=CATEGORY&path1%2C3%2C120"}, {"title"=>"clothing", "url"=>"http://absurdlycool.com/all/clothing-freebies"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10399/training-socks-free-2-pack-of-training-socks-at-lucy-stores"}]}, {"day"=>"Mon, 9 Mar 2009", "links"=>[{"title"=>"Do You Own A Myspace Page, Website Or Blog?", "url"=>"http://www.readysite.com/"}, {"title"=>"Thunderfap", "url"=>"http://www.thunderfap.com/"}, {"title"=>"Yes All 4 Free", "url"=>"http://www.yesall4free.com/"}, {"title"=>"Just Free Stuff", "url"=>"http://www.justfreestuff.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10398/do-you-own-a-myspace-page-website-or-blog"}, {"title"=>"DVD--Free Healthy Home Party DVD ( code: HHP09 / 5984 )", "url"=>"http://www.surveymonkey.com/s.aspx?sm=rdNwplKmLgTDoVT0zh0Dwg_3d_3d"}, {"title"=>"health", "url"=>"http://absurdlycool.com/all/health-freebies"}, {"title"=>"home", "url"=>"http://absurdlycool.com/all/home-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Pumpkinhead", "url"=>"http://www.webspawner.com/users/pumpkinheadtwo/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10395/dvd-free-healthy-home-party-dvd-code-hhp09-5984"}, {"title"=>"Free 2 pack of training socks at Lucy Stores", "url"=>"http://www.lucy.com/jump.jsp?itemID=1047&itemType=CATEGORY&path1%2C3%2C120"}, {"title"=>"clothing", "url"=>"http://absurdlycool.com/all/clothing-freebies"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10396/free-2-pack-of-training-socks-at-lucy-stores"}, {"title"=>"Store Locator", "url"=>"http://www.lucy.com/jump.jsp?itemID=1017&itemType=StoreLocator"}, {"title"=>"Hunt4Freebies", "url"=>"http://www.hunt4freebies.com/"}, {"title"=>"Freebie Reporter", "url"=>"http://www.freebiereporter.com/"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10397/store-locator"}, {"title"=>"Free baby magazines, formula samples, diaper coupons, health information and more", "url"=>"http://lm.logicalmedia.com/z/6186/CD339/"}, {"title"=>"kids", "url"=>"http://absurdlycool.com/all/kids-freebies"}, {"title"=>"Link", "url"=>"http://absurdlycool.com/freebieorsample/10394/free-baby-magazines-formula-samples-diaper-coupons-health-information-and-more"}]}, {"day"=>"\n[view older freebies] ", "links"=>[{"title"=>"view older freebies", "url"=>"http://absurdlycool.com/?h=50"}, {"title"=>"Iteration Labs, LLC", "url"=>"http://iterationlabs.com"}, {"title"=>"Contact us", "url"=>"/contact.cgi"}, {"title"=>"Privacy policy", "url"=>"/privacy.html"}]}]}
@@ -0,0 +1,86 @@
1
+ require "test/unit"
2
+ require File.dirname(__FILE__) + "/../lib/ordered_json"
3
+ require "json"
4
+
5
+ class OrderedJSONTest < Test::Unit::TestCase
6
+
7
+ def test_parse_nothing
8
+ assert_equal OrderedHash.new, OrderedJSON.parse("{}")
9
+ end
10
+
11
+ def test_simple_dump
12
+ assert_equal "{ }", OrderedJSON.dump({})
13
+ end
14
+
15
+ def test_crash_example
16
+ @ruby = eval(File.read(File.dirname(__FILE__) + "/crashing_example.rb"))
17
+ json = OrderedJSON.dump(@ruby)
18
+ @back = OrderedJSON.parse(json)
19
+ assert_equal(@ruby, @back)
20
+
21
+ puts @back.inspect
22
+
23
+ json = OrderedJSON.pretty_dump(@ruby)
24
+ @back = OrderedJSON.parse(json)
25
+ assert_equal(@ruby, @back)
26
+ end
27
+
28
+ def test_invalid_json
29
+ assert_raises(OrderedJSON::ParseError) do
30
+ OrderedJSON.parse("not json")
31
+ end
32
+ end
33
+
34
+ def test_pretty_dump
35
+
36
+ assert_equal File.read(File.dirname(__FILE__) + "/pretty.json"),
37
+ OrderedJSON.pretty_dump({"foo" => "bar",
38
+ "bar" => [{"dsfa" => {"asdf" => ["dsaf", nil]}}]
39
+ })
40
+
41
+ assert_equal %[{\n\t"foo": "bar"\n}], OrderedJSON.pretty_dump({"foo" => "bar"})
42
+ end
43
+
44
+ def test_some_cases
45
+ obj = {"foo"=>{"bar"=>nil}}
46
+ OrderedJSON.dump(obj)
47
+
48
+ obj = OrderedHash.new
49
+ obj["foo"] = {"bar"=>nil}
50
+ OrderedJSON.dump(obj)
51
+
52
+ obj = OrderedHash.new
53
+ obj["foo"] = OrderedHash.new
54
+ OrderedJSON.dump(obj)
55
+ end
56
+
57
+ # The idea is to take random numericish keys with ordered
58
+ # alphabetic values, and assert that when we inspect various
59
+ # parts of the process, despite the random keys, the values are still
60
+ # ordered. See the values scan in assert_alphabet
61
+ def test_parsed_json_maintains_order
62
+ original = create_random_hash
63
+ dump = OrderedJSON.dump(original)
64
+ parsed = OrderedJSON.parse(dump)
65
+
66
+ assert_kind_of OrderedHash, parsed
67
+ assert_alphabet dump
68
+ assert_alphabet parsed.inspect
69
+ assert_equal original, parsed
70
+ end
71
+
72
+ def assert_alphabet(obj)
73
+ alphabet = ("b".."z").to_a.join('')
74
+ found = obj.inspect.scan(/[a-z]/).flatten.join('')
75
+ assert_equal alphabet, found
76
+ end
77
+
78
+ def create_random_hash
79
+ h = OrderedHash.new
80
+ s = "a"
81
+ 25.times do
82
+ h[rand.to_s] = s.succ!.dup
83
+ end
84
+ h
85
+ end
86
+ end
data/test/pretty.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "foo": "bar",
3
+ "bar": [ {
4
+ "dsfa": {
5
+ "asdf": [
6
+ "dsaf",
7
+ null
8
+ ]
9
+ }
10
+ } ]
11
+ }