'How to dynamically parse request body in go fiber?

I have an API built in go fiber. I'm tryng to parse request body data as key value pairs dynamically.

As we know, fiber has context.Body() and context.Bodyparser() methods to do this but I couldn't find any proper example to do this dynamically with these methods.

e.g:

func handler(c *fiber.Ctx) error {
    req := c.Body()
    fmt.Println(string(req))
    
    return nil
}

output:

key=value&key2=value2&key3&value3

What I'm looking for is a dynamic json like:

{
    key:"value",
    key2:"value2",
    key3:"value3",
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source