jsonpath 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/bin/jsonpath +3 -3
- data/jsonpath.gemspec +1 -1
- data/lib/jsonpath/version.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -50,7 +50,13 @@ As well, you can include it as a library.
|
|
50
50
|
You can optionally prevent eval from being called on sub-expressions by passing in :allow_eval => false to the constructor.
|
51
51
|
|
52
52
|
If you'd like to do substitution in a json object, do this:
|
53
|
+
|
54
|
+
~~~~~ {ruby}
|
53
55
|
JsonPath.for({'test' => 'time'}).gsub('$..test') {|v| v << v}
|
56
|
+
~~~~~
|
54
57
|
|
55
58
|
The result will be
|
59
|
+
|
60
|
+
~~~~~ {ruby}
|
56
61
|
{'test' => 'timetime'}
|
62
|
+
~~~~~
|
data/bin/jsonpath
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/local/env ruby
|
2
2
|
|
3
3
|
require 'jsonpath'
|
4
|
-
require '
|
4
|
+
require 'multi_json'
|
5
5
|
|
6
6
|
def usage
|
7
7
|
puts "jsonpath [expression] (file|string)
|
@@ -17,8 +17,8 @@ jsonpath = JsonPath.new(ARGV[0])
|
|
17
17
|
case ARGV[1]
|
18
18
|
when nil #stdin
|
19
19
|
until STDIN.eof?
|
20
|
-
puts
|
20
|
+
puts MultiJson.encode(jsonpath.on(MultiJson.decode(STDIN.readline)))
|
21
21
|
end
|
22
22
|
when String
|
23
|
-
puts
|
23
|
+
puts MultiJson.encode(jsonpath.on(MultiJson.decode(File.exist?(ARGV[1]) ? File.read(ARGV[1]) : ARGV[1])))
|
24
24
|
end
|
data/jsonpath.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
|
23
23
|
# dependencies
|
24
|
-
s.add_runtime_dependency '
|
24
|
+
s.add_runtime_dependency 'multi_json'
|
25
25
|
s.add_development_dependency 'code_stats'
|
26
26
|
s.add_development_dependency 'rake'
|
27
27
|
s.add_development_dependency 'minitest', '~> 2.2.0'
|
data/lib/jsonpath/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: multi_json
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|