Exception or error: I have multiple APIs that follow a similar structure on the high level response. It always gives back an answer in that form: {“data”: {“feed”:[{…}]}, “success”: true} However, the structure in Feed varies, depending on the concrete API. I would now like to build an abstract function to process the various APIs. …
Tag: jsonjson
go – Golang Json Unmarshal numeric with exponent-ThrowExceptions
Exception or error: I have problem when Unmarshal json string into struct that is the numeric value with exponent will alway be 0. Please check code below : package main import ( “encoding/json” “fmt” “os” ) type Person struct { Id uint64 `json:”id”` Name string `json:”name”` } func main() { //Create the Json string var …
go – How to implement a custom json validator-ThrowExceptions
Exception or error: I need to test my system with lots of scenarios. For each scenario I will define the request and expected response, then I will make the request and compare the returned response and expected response. For example, the REST API /add return a+b. request: { “a”:1, “b”:2 } expected response (validator style …
http – Marshal and Unmarshal nested json object with Go-ThrowExceptions
Exception or error: I’m developing a little application using Go. I have a little problem. My application uses “objects” (structs) like this: type Message1 struct { Id string `json:”id”` N int `json:”n”` } This application sends these objects using HTTP to other processes, using the json format. I do the following thing like this (an …
json – Embed go struct into another struct in gorm-ThrowExceptions
Exception or error: I have a database table called http_requests. I have modelled following struct to represent rows in this table. type Map map[string]interface{} type HTTPRequest struct { ID int64 `json:”id” gorm:”id”` RequestURL string `json:”request_url,omitempty” gorm:”request_url”` RequestParams *RequestParams `json:”request_params,omitempty” gorm:”request_params”` } // RequestParams is another struct that holds params from body and URL query type …
What are the differences between JSON and JSONP?-ThrowExceptions
Exception or error: Format wise, file type wise and practical use wise? How to solve: JSONP is JSON with padding, that is, you put a string at the beginning and a pair of parenthesis around it. For example: //JSON {“name”:”stackoverflow”,”id”:5} //JSONP func({“name”:”stackoverflow”,”id”:5}); The result is that you can load the JSON as a script file. …
json – How to convert s3EventRecord from AWS SNS to map (Go)-ThrowExceptions
Exception or error: My data flow is as follows: File is uploaded to s3 bucket s3 bucket triggers SNS topic SNS topic passes s3 event as a message to lambda Lambda is triggered by SNS and attempts to read record.SNS.Message I try to convert the message (escaped JSON) to map for easy parsing. I tried …
go – Has Json tag but not exported-ThrowExceptions
Exception or error: This question already has answers here: JSON and dealing with unexported fields (2 answers) (un)marshalling json golang not working (2 answers) Closed 2 years ago. Begining to study golang. Task: Get Json and Unmarshall it. But I get mistake: Json tag but not exported How to make unexported fields become exported and …
How to Marshall json from one struct to another with different json tags in Go?-ThrowExceptions
Exception or error: I am creating a Go application that consumes data from multiple sources that all have similar data but different structures to their data/responses. These responses need to be marshalled into a common struct that is then sent to another service. Common struct: type common struct { ID string `json:id` GivenName string `json:given_name` …
json – MarshalJSON a non-exported type (datastore.Key)-ThrowExceptions
Exception or error: I’m using Google Datastore. I have a query that returns a slice of entities. Each entity includes a datastore key. I need to marshal this slice of entities to JSON, so I used encoding/json.MarshalJSON. The problem is *datastore.Key has a custom MarshalJSON method which base64 encodes the key value, which I don’t …