Giter Site home page Giter Site logo

Comments (2)

mihaitodor avatar mihaitodor commented on September 21, 2024

Hey @sesa657547 👋 Here's how I'd do it:

input:
  generate:
    count: 1
    mapping: |
      root = [
        {
          "dId": "kjglsjglfkgfdkgfhjfhdsj",
          "d1": "fhkfjsaf",
          "d2": {
            "dc1": 8,
            "dc2": 9
          },
          "timestamp": "2020-09-03",
          "A": [
            {
              "aId": "jflksflskgskg",
              "af1": "kkfls",
              "af2": {
                "ac1": 6,
                "ac2": 2
              },
              "af3": 1,
              "af4": "00",
              "af5": 4
            }
          ],
          "B": [
            {
              "bId": "jgljgldjgs",
              "bf1": 6,
              "bf2": {
                "bc1": 4,
                "bc2": 2
              }
            }
          ],
          "C": [
            {
              "cId": "njfglsjg",
              "cf1": 3,
              "cf2": "jfgg"
            }
          ]
        }
      ]
  processors:
    - mapping: |
        root = this.0.with("A", "B", "C").key_values()
    - unarchive:
        format: json_array
    - mapping: |
        meta key = this.key

        root = this.value

output:
  kafka:
    # ...
    topic: ${! @key }
    # ...

I used the generate input to show you how you can test this payload as a standalone example.

If A, B and C aren't the actual topic names, you can massage them further using bloblang inside ${! ... }, or if you just need to prepend / append some string to them, you can also do stuff like foo-${! @key }-bar.

from benthos.

Jeffail avatar Jeffail commented on September 21, 2024

Moving to discussion (#2026)

from benthos.

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.