embulk-filter-json_key 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 10ca802406bca013bdbab6acb7e5905398f6c6a9
4
- data.tar.gz: 0e3539b540784dac7bea4a6d4c955e913910f4ba
3
+ metadata.gz: edac8b3c9d2d31c8c173cec8ea9580263e36f621
4
+ data.tar.gz: 60ed7bf6d0cc124e0aa91abed0d68615b5403f23
5
5
  SHA512:
6
- metadata.gz: 3edb3f9854921e03142c802bad6e4b68b55449aef42d41f6fade97b2e39c637dcf955adade9e8aa623797849e44f1ca85065335eb69445fe2a19f30b35b050c1
7
- data.tar.gz: 79a62c4ffef8cd77a64f5cf41ae4bdc3caa5e408508e5cac8b501cc6c726f50b0be7543667cfdbfea5e07603b4d6b194240e75a873000f69244571903b32804b
6
+ metadata.gz: f5ed0b5a8feaa5d160a79ecc2ca6bd8303ec86be3a80e549796671639314ef92e01f4a322c3d3ccbaf95371f07c4846a51bf7b44a6e6a2b0d8062d904cdd2fd3
7
+ data.tar.gz: e46e499ca06813f85c2bd8330f3838c314059b02c988295b5f2055483f438f21a853e85f42263a399d4d60410c6a716ffddf5210399fb9b026c81abf0659f926
@@ -12,7 +12,7 @@ configurations {
12
12
  provided
13
13
  }
14
14
 
15
- version = "0.0.1"
15
+ version = "0.0.2"
16
16
  sourceCompatibility = 1.7
17
17
  targetCompatibility = 1.7
18
18
 
@@ -102,6 +102,10 @@ class JsonKeyFilter
102
102
  // TODO: addKey is overwriting existing values.
103
103
  private JsonNode addKey(JsonNode node, List<String> nestedKey, JsonNode value)
104
104
  {
105
+ if (node == null) {
106
+ return null;
107
+ }
108
+
105
109
  if (node.isObject()) {
106
110
  return addKeyToObject(node, nestedKey, value);
107
111
  }
@@ -131,7 +135,9 @@ class JsonKeyFilter
131
135
  String parentKey = nestedKey.get(0);
132
136
  List<String> newNestedKey = nestedKey.subList(1, nestedKey.size());
133
137
  JsonNode newNode = addKey(object.get(parentKey), newNestedKey, value);
134
- object.set(parentKey, newNode);
138
+ if (newNode != null) {
139
+ object.set(parentKey, newNode);
140
+ }
135
141
  return object;
136
142
  }
137
143
  }
@@ -156,7 +162,9 @@ class JsonKeyFilter
156
162
  if (NumberUtils.isNumber(parentIdx)) {
157
163
  int idx = Integer.parseInt(parentIdx);
158
164
  JsonNode newNode = addKey(object.get(idx), newNestedKey, value);
159
- object.set(idx, newNode);
165
+ if (newNode != null) {
166
+ object.set(idx, newNode);
167
+ }
160
168
  }
161
169
  return object;
162
170
  }
@@ -184,6 +192,10 @@ class JsonKeyFilter
184
192
  // if NullNode has come before end of a nested key, return NullNode not EmptyObjectNode.
185
193
  private JsonNode dropKey(JsonNode node, List<String> nestedKey)
186
194
  {
195
+ if (node == null) {
196
+ return null;
197
+ }
198
+
187
199
  if (node.isObject()) {
188
200
  return dropKeyFromObject(node, nestedKey);
189
201
  }
@@ -209,7 +221,9 @@ class JsonKeyFilter
209
221
  String parentKey = nestedKey.get(0);
210
222
  List<String> newNestedKey = nestedKey.subList(1, nestedKey.size());
211
223
  JsonNode newNode = dropKey(object.get(parentKey), newNestedKey);
212
- object.set(parentKey, newNode);
224
+ if (newNode != null) {
225
+ object.set(parentKey, newNode);
226
+ }
213
227
  return object;
214
228
  }
215
229
  }
@@ -233,7 +247,9 @@ class JsonKeyFilter
233
247
  if (NumberUtils.isNumber(parentIdx)) {
234
248
  int idx = Integer.parseInt(parentIdx);
235
249
  JsonNode newNode = dropKey(object.get(idx), newNestedKey);
236
- object.set(idx, newNode);
250
+ if (newNode != null) {
251
+ object.set(idx, newNode);
252
+ }
237
253
  }
238
254
  return object;
239
255
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-json_key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Civitaspo
@@ -64,7 +64,7 @@ files:
64
64
  - src/test/java/org/embulk/filter/json_key/TestAddKeyFilter.java
65
65
  - src/test/java/org/embulk/filter/json_key/TestDropKeyFilter.java
66
66
  - src/test/java/org/embulk/filter/json_key/TestJsonKeyFilterPlugin.java
67
- - classpath/embulk-filter-json_key-0.0.1.jar
67
+ - classpath/embulk-filter-json_key-0.0.2.jar
68
68
  homepage: https://github.com/civitaspo/embulk-filter-json_key
69
69
  licenses:
70
70
  - MIT