Comments (5)
Questions:
- How can I aggregate "a" and "b" to one value (if all values are the same)?
Jolt / Shift does not do aggregates, it just transforms the structure of your data.
That said, it can transform your data into a structure that is easier for you to aggregate.
With "a" : [ "t1", "t1", "t1" ] , it is easier to see if all the values are the same.
- How can I add to elements of array "c" some children from top level of json?
Looking at your example, I think I see what you want to accomplish.
if ( c == t3 ) then grab "d" and "e" and nest them under c.t3[]
else if ( c == t4 ) then grab "d" and "e" and nest them under c.t4[]
That is custom logic, and you would need to write a Java Transform.
- Maybe another questions will appear later
or maybe this problem cannot be resolved using lastest (0.0.12) version of JOLT?
Yeah, there are ideas on how to do this, but no definative plans.
from jolt.
- Understood, thank you
- Sorry, maybe I was poorly expressed.
Can I add child nodes to this array's ( { "c" : [ "t3", "t3", "t4" ] } - it is from result)
elements for get json like this:
{
"c": {
"t3": [
{
"d": "t5",
"e": "t8"
},
{
"d": "t6",
"e": "t9"
}
],
"t4": [
{
"d": "t7",
"e": "t10"
}
]
}
}
Thanks
Update:
2. Yes, You are right. I know how to do it in Java :) Maybe in future release it would be available in JOLT :)
Thanks for answering my question 👍
from jolt.
When I look at where "d": "t5" came from, it looks like you are trying to "group by" c == t3.
Best "shift" could do is strip out "a" and "b" from each input.
Spec of
[
{
"operation": "shift",
"spec": {
"*": {
"a": "A",
"b": "B",
"c|d|e": "C[&1].&"
}
}
}
]
Produces :
{
"A" : [ "t1", "t1", "t1" ],
"B" : [ "t2", "t2", "t2" ],
"C" : [
{
"c" : "t3",
"d" : "t5",
"e" : "t8"
},
{
"c" : "t3",
"d" : "t6",
"e" : "t9"
},
{
"c" : "t4",
"d" : "t7",
"e" : "t10"
}
]
}
from jolt.
Yes, the best name for that I need to do is "group by".
Thanks for Your example but this is not exactly what I need.
I understood that now I cannot use JOLT for my task, maybe later:)
from jolt.
If you are willing to do a series of Shifts, it can get you the unique values of "a" and "b"
Input : Note I changed the 2nd "a = t1" to "a = t2".
[
{
"a": "t1",
"b": "t2",
"c": "t3",
"d": "t5",
"e": "t8"
},
{
"a": "t2",
"b": "t2",
"c": "t3",
"d": "t6",
"e": "t9"
},
{
"a": "t1",
"b": "t2",
"c": "t4",
"d": "t7",
"e": "t10"
}
]
Spec
[
{
"operation": "shift",
"spec": {
"*": {
"a": "A",
"b": "B"
}
}
},
{
"operation": "shift",
"spec": {
"A": {
"*": {
"*": "a.&"
}
},
"B": {
"*": {
"*": "b.&"
}
}
}
},
{
"operation": "shift",
"spec": {
"a|b": {
"*": {
"$": "&2"
}
}
}
}
]
Output
{
"a" : [ "t1", "t2" ],
"b" : "t2"
}
from jolt.
Related Issues (20)
- remove null from simple type array
- ifElse multiple conditions? HOT 2
- Demo site source code
- Input JSON lost when doing a date concat
- bug on reading timestamp value HOT 1
- Sort wont work on an Array of complex Objects HOT 1
- squashNulls and recursivelySquashNulls need to work on arrays HOT 1
- concat elements of array HOT 3
- min\max for arrays
- Why is the key obtained from "&2" not "rating" HOT 6
- Help with Jolt transformation spec HOT 2
- How to compare fields between 2 JSON objects and create a response JSON in Jolt
- getrandom - target is not supported
- How to add an object to the end of an array with unknown length HOT 5
- Jo;t spec to remove fields having null and empty in the json having arraylist HOT 1
- need to replace a string using modify-overwrite-beta, REPLACE ABC string from attributes HOT 3
- how to read required attributes from a config file HOT 3
- What is jolt conversion spec for the given input and output
- The constructor of com.bazaarvoice.jolt.common.pathelement.StarDoublePathElement class could throw an unexpected ArrayIndexOutOfBoundsException
- Jolt Transformer for Splitting a field value HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jolt.