"parsing json data object in golang example" Code Answer's
You're definitely familiar with the best coding language Go that developers use to develop their projects and they get all their queries like "parsing json data object in golang example" answered properly. Developers are finding an appropriate answer about parsing json data object in golang example related to the Go coding language. By visiting this online portal developers get answers concerning Go codes question like parsing json data object in golang example. Enter your desired code related query in the search bar and get every piece of information about Go code related question on parsing json data object in golang example.
parsing json data object in golang example
package main
import (
"encoding/json"
"fmt"
)
func main() {
//Simple Employee JSON object which we will parse
empJson := `{
"id": 11,
"name": "Irshad",
"department": "IT",
"designation": "Product Manager",
"address": {
"city": "Mumbai",
"state": "Maharashtra",
"country": "India"
}
}`
// Declared an empty interface
var result map[string]interface{}
// Unmarshal or Decode the JSON to the interface.
json.Unmarshal([]byte(empJson), &result)
address := result["address"].(map[string]interface{})
//Reading each value by its key
fmt.Println("Id :", result["id"],
"\nName :", result["name"],
"\nDepartment :", result["department"],
"\nDesignation :", result["designation"],
"\nAddress :", address["city"], address["state"], address["country"])
}
All those coders who are working on the Go based application and are stuck on parsing json data object in golang example can get a collection of related answers to their query. Programmers need to enter their query on parsing json data object in golang example related to Go code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about parsing json data object in golang example for the programmers working on Go code while coding their module. Coders are also allowed to rectify already present answers of parsing json data object in golang example while working on the Go language code. Developers can add up suggestions if they deem fit any other answer relating to "parsing json data object in golang example". Visit this developer's friendly online web community, CodeProZone, and get your queries like parsing json data object in golang example resolved professionally and stay updated to the latest Go updates.