Can you dynamically build json from a MSSQL DB Query without having a struct defining the content?

I want to create an APP that serve a webpage with a Data Grid that dynamically show the results of a unknown SQL Query that will be supplied in a text file.

The scenario: Our consultants Creating a query and place it in an SQL.ini file in the same folder as the go program. The first time it runs it will ask the SQL credential details then encrypt and save it it to a setup.ini file.

This can be set up as a service or a standalone App.

I’ll appreciate any assistance with this query, don’t want to do it in C#. Would Love doing it in GO.

You can create a map dinamically and the generated a JSON string from it. For example

package main

import (

func main() {
obj := map[string]interface{}{}
obj[“hoge”] = "huga"
obj[“Nombre”] = "Pepe"
obj[“Sueldo”] = 10.25

 jsonString, _ := json.Marshal(obj)


Just need to create obj according your fields in the .ini file…


1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.