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 +4 -4
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/filter/json_key/JsonKeyFilter.java +20 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edac8b3c9d2d31c8c173cec8ea9580263e36f621
|
4
|
+
data.tar.gz: 60ed7bf6d0cc124e0aa91abed0d68615b5403f23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ed0b5a8feaa5d160a79ecc2ca6bd8303ec86be3a80e549796671639314ef92e01f4a322c3d3ccbaf95371f07c4846a51bf7b44a6e6a2b0d8062d904cdd2fd3
|
7
|
+
data.tar.gz: e46e499ca06813f85c2bd8330f3838c314059b02c988295b5f2055483f438f21a853e85f42263a399d4d60410c6a716ffddf5210399fb9b026c81abf0659f926
|
data/build.gradle
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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.
|
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
|