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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cb00933d27049f27e48ce4ad2cb134d9b06a92980bd7671db6fc05cd4403735
4
- data.tar.gz: c1f95628a4649757d0b43231100d106c509aa735bb033a70fb63457f21cfbc1d
3
+ metadata.gz: ac39771f7b1358e30e26bfdc81b5b4ad5ac493238e84142e31331648f96fa37e
4
+ data.tar.gz: 69a0d03f65e05dfb292ae01f950986822ec04991771968ede64c63c6f202d99f
5
5
  SHA512:
6
- metadata.gz: 78a85dde7ffef115d49797c4eeebbd794061a02141e07e7f86c4297e7361bf5e77b6da99fa9a529e9064fd33a1bc2981f5e14eeae35878f0b2be6f0e2b3ea54d
7
- data.tar.gz: 17100164f78a48b3cfbeee7b1b3cf694c1807f7cfa27536316bf45e422c7a031dc86368e1d14ce64dc7795b6b944451ac499f89b02472e9339f2ee7a026cc53e
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
- ```ruby
128
+ ```json
129
129
  {
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'
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
  }
@@ -39,11 +39,17 @@ class JsonDataExtractor
39
39
 
40
40
  # TODO yeah, this looks ugly. Address it later.
41
41
  if !array_type
42
- results[key] = results[key].first unless 1 < results[key].size
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
@@ -1,3 +1,3 @@
1
1
  class JsonDataExtractor
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.8'
3
3
  end
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.6
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-04-10 00:00:00.000000000 Z
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.0.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