Formatting MQTT-output

Rather new with telegraf and I’m having a problem.
I’m reading data from modbus, that’s OK.
My problem is that I need some of that data sent to MQTT in JSON-format. That works, but only partially.
The data I need to send to MQTT is like this :

  "Pac" : 175.0,
  "E-Total" : 40834.27

What I succeeded to do is this :

  "fields" : {
    "E-Total" : 58343,
    "Pac" : 330
  "name" : "modbus",
  "tags" : {
    "dc" : "server1",
    "host" : "server1",
    "name" : "SMA-inverter1",
    "slave_id" : "3",
    "type" : "holding_register"
  "timestamp" : 1699707510

The device that is subscribed to the topic can’t handle this.
How do I remove those “superfluous” items ?
I tried using layout = "field", but then, the data is not JSON-formatted, it’s just two new topics.
I was suggested to read this. Is that the way to go ? If yes, where can I find the documentation (plugins ?) ?

Replying to my own post :cold_face:
After reading/searching more I found this :

json_transformation = '''

Now it works.

Hello @Koenraad,
Thank you for including a solution to your answer!