Using VBA and VBA-JSON to access JSON data from WordPress API

The JsonConverter is returning a collection of VBA.Collections Scripting.Dictionaries, and Values. In order to understand the output you will have to test the TypeName of all the returned values. The real question is “How to navigate through a json object (or any unknown object for that matter) and access the values within. Immediate Window Using … Read more

Error handling using JSONDecoder in Swift

Never print error.localizedDescription in a decoding catch block. This returns a quite meaningless generic error message. Print always the error instance. Then you get the desired information. let decoder = JSONDecoder() if let data = data { do { // process data } catch { print(error) } } Or for the full set of errors … Read more

How to open Visual Studio Code’s ‘settings.json’ file?

To open the User settings: Open the command palette (either with F1 or Ctrl+Shift+P) Type “open settings” You are presented with a few optionsĀ¹, choose Open User Settings (JSON) This image was taken in the VS Code online editor Which, from the manual and depending on platform, is one of: Windows %APPDATA%\Code\User\settings.jsonĀ² macOS $HOME/Library/Application\ Support/Code/User/settings.json … Read more

In postgresql, how can I return a boolean value instead of string on a jsonb key?

Simply cast a text to boolean: create table jsonb_test (id int, data jsonb); insert into jsonb_test values (1, ‘{“is_boolean” : true}’), (2, ‘{“is_boolean” : false}’); select id, data, (data->>’is_boolean’)::boolean as is_boolean from jsonb_test where (data->>’is_boolean’)::boolean id | data | is_boolean —-+————————+———— 1 | {“is_boolean”: true} | t (1 row) Note that you can also cast … Read more

Typescript `enum` from JSON string

If you are using Typescript before the 2.4 release, there is a way to achieve that with enums by casting the values of your enum to any. An example of your first implementation enum Type { NEW = <any>”NEW”, OLD = <any>”OLD”, } interface Thing { type: Type } let thing:Thing = JSON.parse(‘{“type”: “NEW”}’); alert(thing.type … Read more

How to access remote data and write it into a file during Nuxt build?

You can start by installing axios (you can still have @nuxtjs/axios alongside your project): yarn add -D axios Then, let’s take JSON placeholder’s API for testing purposes, we will try to get the content located here: https://jsonplaceholder.typicode.com/todos/1 And save it to a local .json file in our Nuxt project. For that, head towards nuxt.config.js and … Read more

JSON single value parsing

You can decode into a map[string]interface{} and then get the element by key. func main() { b := []byte(`{“ask_price”:”1.0″}`) data := make(map[string]interface{}) err := json.Unmarshal(b, &data) if err != nil { panic(err) } if price, ok := data[“ask_price”].(string); ok { fmt.Println(price) } else { panic(“wrong type”) } } Structs are often preferred as they are … Read more