You gave two different things you want to accomplish:

1. “I am trying to read those values and store in DB”
2. “I will populate the struct and provide it the application for 
consumption”

Fortunately accomplishing either or both of these goals follows a similar 
process.

Start by figuring out what the output should be. In the case of a DB, the 
schema the data will be put into. For providing it to the application, the 
data structures you want. You mentioned using range, which means the data 
you want to range over needs to be in a slice or a map.

Then extract and transform the input into the output.

Some guesses I have made about your data:

- There are a variable number of applications and their names aren’t known 
before you get the data.
- Applications have different parameters
- Parameter types default to the contents of “parameterType”, in this case 
“common”

Assuming these guesses are correct, I would unmarshal the json into:

struct {
JsonData []struct {
DataReference []struct {
ParameterType   string `json:"parameterType"`
ApplicationType map[string]map[string]interface{}
} `json:"dataReference"`
} `json:"jsondata"`
}

This sets out the known portions and leaves the variable portions for later 
handling.

Then iterate over ApplicationType to get the different applications and 
their parameters. Populate the database or desired data structures during 
the loop.

An example of this process: https://play.golang.org/p/TNYur-Lr2Z 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to