embulk-parser-jsonpath 0.4.0-java → 0.4.1-java

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: a87bff6b027aa8ab4fdaa982a772298aef9f94454868bf5790511b1b811ee9de
4
- data.tar.gz: 43397c117f366421b77e54103077e2a473d1962496023f2582e70866dbfb559a
3
+ metadata.gz: bf651c111217bef8a97e2ba2efed0236d0452d6ed249f4e6c2d2f9cf8887d73d
4
+ data.tar.gz: e5c758818fc28e1e3ca8b69d793c695f9e7d61bf5fccfb2e33be92c03051ee89
5
5
  SHA512:
6
- metadata.gz: e2988b7ef249fe72cb5aaf88431a750e4dc2822749365bff902f93c0bfc21b909a6fa267e90621555a59043894251ab46741777b4691e3625d372bd617107534
7
- data.tar.gz: 1233e36a031f1ee960752f2808698168c4b40d3f82ce56593223d9ae692e8d2f814993bea429267e5b19129ea4dfac688f19bd0fb729a60c553d5b9ce4d0c0c1
6
+ metadata.gz: a5b1bd0ebcc0b34cf0871e3bebc181e100635da74aef8f70cc9a1d9824b06f119a28cc0282a444c8fdfb958e75cb6de4d69571ff2460371c6ea5b8900885e3dc
7
+ data.tar.gz: 9d9c528e2e1e150a0162824beb6ffc70d23dfa90a7daf93721eae0877c95b1c4b8cc3f22c10dd0dd78b5bf30999946e3c79690148486ebd0226c05662b32d899
@@ -10,21 +10,22 @@ module Embulk
10
10
  parser_config = config.param("parser",:hash)
11
11
  json_path = parser_config.param("root",:string,default: "$")
12
12
  json = JsonPath.new(json_path).on(sample_text).first
13
- if( json.kind_of?(Array) )
14
- no_hash = json.find{ |j| !j.kind_of?(Hash) }
15
- raise RuntimeError,"Can't exec guess. The row data must be hash." if no_hash
16
- columns = Embulk::Guess::SchemaGuess.from_hash_records(json).map do |c|
17
- column = {name: c.name, type: c.type}
18
- column[:format] = c.format if c.format
19
- column
20
- end
21
- parser_guessed = {"type" => "jsonpath"}
22
- parser_guessed["columns"] = columns
23
- return {"parser" => parser_guessed}
24
- else
25
- raise RuntimeError,"Can't guess specified the JSONPath: #{json_path}. The results does not return an Array."
26
- end
27
13
 
14
+ # The rest of code expect a data type like `[ {}, {}, {}]`.
15
+ # If JSONPath specifies a Hash object, it needs to pack a hash object into an array.
16
+ # ex. { "name": "bob", "age":24" } -> [ { "name": "bob", "age":24 } ]
17
+ json = [json] unless json.is_a?(Array)
18
+
19
+ no_hash = json.find{ |j| !j.kind_of?(Hash) }
20
+ raise RuntimeError,"Can't exec guess. The row data must be hash." if no_hash
21
+ columns = Embulk::Guess::SchemaGuess.from_hash_records(json).map do |c|
22
+ column = {name: c.name, type: c.type}
23
+ column[:format] = c.format if c.format
24
+ column
25
+ end
26
+ parser_guessed = {"type" => "jsonpath"}
27
+ parser_guessed["columns"] = columns
28
+ return {"parser" => parser_guessed}
28
29
  end
29
30
  end
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-parser-jsonpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: java
6
6
  authors:
7
7
  - Hiroyuki Sato
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-27 00:00:00.000000000 Z
12
+ date: 2023-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ extra_rdoc_files: []
49
49
  files:
50
50
  - classpath/accessors-smart-1.2.jar
51
51
  - classpath/asm-5.0.4.jar
52
- - classpath/embulk-parser-jsonpath-0.4.0.jar
52
+ - classpath/embulk-parser-jsonpath-0.4.1.jar
53
53
  - classpath/embulk-util-config-0.3.1.jar
54
54
  - classpath/embulk-util-file-0.1.3.jar
55
55
  - classpath/embulk-util-json-0.1.1.jar