Git Product home page Git Product logo

Comments (5)

loicmathieu avatar loicmathieu commented on June 24, 2024 2

@aku the Jackson library is in the classpath, you may be able to use it to process JSON.

from kestra.

aku avatar aku commented on June 24, 2024 1

Built in support for JSON is certainly welcome. In my case I was disappointed with Jython performance (I do a simple transformation of array of data which includes parsing JSON string) so I've decided to try other FileTranform tasks/plugins.
Nashorn doesn't support returning multiple rows, Groovy can't parse JSON. So I stuck with Jython

from kestra.

aku avatar aku commented on June 24, 2024 1

@aku the Jackson library is in the classpath, you may be able to use it to process JSON.

Hi @loicmathieu
Thanks! It took me a while to figure out how to use it but I managed to parse JSON objects using Jackson lib.
Here is a snippet:

      import com.fasterxml.jackson.*

      def jsonStr = '{ "name": "John Doe", "age": 99, "embedded": {"foo": "bar"} }';

      def mapper = new databind.ObjectMapper();
      def typeRef = new core.type.TypeReference<HashMap<String,Object>>() {};

      data = mapper.readValue(jsonStr, typeRef);
      
      logger.info('json object: {}', data);
      logger.info('embedded field: {}', data.embedded.foo)

Maybe you can update plugin documentation to provide some examples for other users?
Also, it would be nice to know plugin's limitations

from kestra.

anna-geller avatar anna-geller commented on June 24, 2024

good catch, we'll get back to you on that on Monday

btw would this task be useful in your use case? we were thinking of adding support for JSONata #3148

from kestra.

anna-geller avatar anna-geller commented on June 24, 2024

Hey, I got the following response from the team: "In process (in JVM) script tasks will never be able to install any packages due to security reasons. They are more performant than scripts in external processes but with fewer features."

This means we are not able to install any external Groovy libraries including JSON. To use JSON packages, you will need to use Node.js or Python script task instead (or JSONata once we add it).

from kestra.

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.