Handling JSON Post Request in Go

Please use json.Decoder instead of json.Unmarshal. func test(rw http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) var t test_struct err := decoder.Decode(&t) if err != nil { panic(err) } log.Println(t.Test) }

Display curl output in readable JSON format in Unix shell script

A few solutions to choose from: json_pp: command utility available in Linux systems for JSON decoding/encoding echo ‘{“type”:”Bar”,”id”:”1″,”title”:”Foo”}’ | json_pp -json_opt pretty,canonical { “id” : “1”, “title” : “Foo”, “type” : “Bar” } You may want to keep the -json_opt pretty,canonical argument for predictable ordering. jq: lightweight and flexible command-line JSON processor. It is written … Read more

How do I modify fields inside the new PostgreSQL JSON datatype?

Update: With PostgreSQL 9.5, there are some jsonb manipulation functionality within PostgreSQL itself (but none for json; casts are required to manipulate json values). Merging 2 (or more) JSON objects (or concatenating arrays): SELECT jsonb ‘{“a”:1}’ || jsonb ‘{“b”:2}’, — will yield jsonb ‘{“a”:1,”b”:2}’ jsonb ‘[“a”,1]’ || jsonb ‘[“b”,2]’ — will yield jsonb ‘[“a”,1,”b”,2]’ So, … Read more

Importing JSON file in TypeScript

With TypeScript 2.9.+ you can simply import JSON files with benefits like typesafety and intellisense by doing this: import colorsJson from ‘../colors.json’; // This import style requires “esModuleInterop”, see “side notes” console.log(colorsJson.primaryBright); Make sure to add these settings in the compilerOptions section of your tsconfig.json (documentation): “resolveJsonModule”: true, “esModuleInterop”: true, Side notes: Typescript 2.9.0 has … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)