yaji 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +25 -2
  2. data/lib/yaji/version.rb +1 -1
  3. metadata +1 -1
@@ -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
  -------
@@ -18,5 +18,5 @@
18
18
  #
19
19
 
20
20
  module YAJI
21
- VERSION = "0.2.1"
21
+ VERSION = "0.2.2"
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: