Git Product home page Git Product logo

Comments (3)

milosimpson avatar milosimpson commented on August 22, 2024

Not quite. It can do:

"foods" : [ "Salad", "Fish", "Shellfish", "Vegetarian" ]

Jolt is about transforming the JSON structure of your data, not "transforming" / running arbitrary logic on the content of your data.
As such, it can put your data into a JSON Array, but it can't run a String concatenation on it.

I created a unit test (for Chainr) with this transform. You can see the spec to generate the "foods" array here :

{
    "input": {
        "food_pairing": [
            {
                "food_id": "7",
                "food_name": "Salad"
            },
            {
                "food_id": "12",
                "food_name": "Fish"
            },
            {
                "food_id": "13",
                "food_name": "Shellfish"
            },
            {
                "food_id": "19",
                "food_name": "Vegetarian"
            }
        ]
    },

    "spec": [
        {
            "operation" : "shift",
            "spec" : {
                "food_pairing": {
                    "*": {
                         // put the Json value found at input key "food_name",  
                         // under the output key "foods" where the JSON value at "foods" is an array
                        "food_name": "foods[]"  
                    }
                }
            }
        }
    ],

    "expected": {
        "foods" : [ "Salad", "Fish", "Shellfish", "Vegetarian" ]
    }
}

I hope that helps.

from jolt.

geocine avatar geocine commented on August 22, 2024

Thanks for replying, that is how I did it a whle ago. I saw it on the documentation. I accomplished the concatenation using Jackson's ObjecNode.

from jolt.

milosimpson avatar milosimpson commented on August 22, 2024

Cool.

from jolt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.