json_data_extractor 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/json_data_extractor.rb +8 -2
- data/lib/src/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac39771f7b1358e30e26bfdc81b5b4ad5ac493238e84142e31331648f96fa37e
|
4
|
+
data.tar.gz: 69a0d03f65e05dfb292ae01f950986822ec04991771968ede64c63c6f202d99f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403b5b95e7bfc0b7f530021980a10407f08be499092a80550a2dc55df7aeabc64197f68e6bf44f98c19be4ea8d57884db1205490970a57552ea924cf673c0f8a
|
7
|
+
data.tar.gz: 58260729ea70e88fdd1937cbbac0cffac998ce9dab686dedbbcb110e7618edd72a9bd71e494bfdc7441665a306e3ead800d9558b4c80b2fce525de3c70f90eee
|
data/README.md
CHANGED
@@ -125,18 +125,18 @@ JDE supports nested schemas. Just provide your element with a type of `array` an
|
|
125
125
|
|
126
126
|
E.g. this is a valid real-life schema with nested data:
|
127
127
|
|
128
|
-
```
|
128
|
+
```json
|
129
129
|
{
|
130
|
-
name:
|
131
|
-
code:
|
132
|
-
services:
|
133
|
-
locations: {
|
134
|
-
path:
|
135
|
-
type:
|
136
|
-
schema: {
|
137
|
-
name:
|
138
|
-
type:
|
139
|
-
code:
|
130
|
+
"name": "$.Name",
|
131
|
+
"code": "$.Code",
|
132
|
+
"services": "$.Services[*].Code",
|
133
|
+
"locations": {
|
134
|
+
"path": "$.Locations[*]",
|
135
|
+
"type": "array",
|
136
|
+
"schema": {
|
137
|
+
"name": "$.Name",
|
138
|
+
"type": "$.Type",
|
139
|
+
"code": "$.Code"
|
140
140
|
}
|
141
141
|
}
|
142
142
|
}
|
data/lib/json_data_extractor.rb
CHANGED
@@ -39,11 +39,17 @@ class JsonDataExtractor
|
|
39
39
|
|
40
40
|
# TODO yeah, this looks ugly. Address it later.
|
41
41
|
if !array_type
|
42
|
-
|
42
|
+
if nested
|
43
|
+
results[key] = self.class.new(results[key].first, @modifiers).extract(nested)
|
44
|
+
# todo there might be a problem if results[key] yields more than 1 item
|
45
|
+
# Yeah, we'll get back to it later. Or send your PRs
|
46
|
+
else
|
47
|
+
results[key] = results[key].first unless 1 < results[key].size
|
48
|
+
end
|
43
49
|
elsif nested
|
44
50
|
results[key] = []
|
45
51
|
Array(extracted_data).each do |item|
|
46
|
-
results[key] << self.class.new(item).extract(nested)
|
52
|
+
results[key] << self.class.new(item, @modifiers).extract(nested)
|
47
53
|
end
|
48
54
|
end
|
49
55
|
end
|
data/lib/src/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_data_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Buslaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.2.3
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Transform JSON data structures with the help of a simple schema and JsonPath
|