yaji 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +25 -2
- data/lib/yaji/version.rb +1 -1
- metadata +1 -1
data/README.markdown
CHANGED
@@ -78,7 +78,7 @@ will print only one line:
|
|
78
78
|
But it might be more useful to yield items from inner array:
|
79
79
|
|
80
80
|
parser = YAJI::Parser.new('{"size":2,"items":[{"id":1}, {"id":2}]}')
|
81
|
-
parser.each("items/") do |obj|
|
81
|
+
parser.each("/items/") do |obj|
|
82
82
|
puts obj.inspect
|
83
83
|
end
|
84
84
|
|
@@ -93,7 +93,7 @@ specify additional selector if you need to fetch some sibling nodes,
|
|
93
93
|
e.g. `"size"` from previous example:
|
94
94
|
|
95
95
|
parser = YAJI::Parser.new('{"size":2,"items":[{"id":1}, {"id":2}]}')
|
96
|
-
parser.each(["size", "items/"]) do |obj|
|
96
|
+
parser.each(["size", "/items/"]) do |obj|
|
97
97
|
puts obj.inspect
|
98
98
|
end
|
99
99
|
|
@@ -103,6 +103,29 @@ it yields
|
|
103
103
|
{"id"=>1}
|
104
104
|
{"id"=>2}
|
105
105
|
|
106
|
+
Parse objects in top-level array. Without any parameters parser will
|
107
|
+
produce single object for the input:
|
108
|
+
|
109
|
+
parser = YAJI::Parser.new('[{"id":1}, {"id":2}]')
|
110
|
+
parser.each do |obj|
|
111
|
+
puts obj.inspect
|
112
|
+
end
|
113
|
+
|
114
|
+
Output:
|
115
|
+
|
116
|
+
[{"id"=>1}, {"id"=>2}]
|
117
|
+
|
118
|
+
But you and interate over inner objects passing `"/"` as the argument:
|
119
|
+
|
120
|
+
parser = YAJI::Parser.new('[{"id":1}, {"id":2}]')
|
121
|
+
parser.each("/") do |obj|
|
122
|
+
puts obj.inspect
|
123
|
+
end
|
124
|
+
|
125
|
+
Output:
|
126
|
+
|
127
|
+
{"id"=>1}
|
128
|
+
{"id"=>2}
|
106
129
|
|
107
130
|
LICENSE
|
108
131
|
-------
|
data/lib/yaji/version.rb
CHANGED