Partly JSON unmarshal into a map in Go

This can be accomplished by Unmarshaling into a map[string]json.RawMessage. var objmap map[string]json.RawMessage err := json.Unmarshal(data, &objmap) To further parse sendMsg, you could then do something like: var s sendMsg err = json.Unmarshal(objmap[“sendMsg”], &s) For say, you can do the same thing and unmarshal into a string: var str string err = json.Unmarshal(objmap[“say”], &str) EDIT: Keep … Read more

How can I iterate over a map of ?

What about entrySet() HashMap<String, Person> hm = new HashMap<String, Person>(); hm.put(“A”, new Person(“p1”)); hm.put(“B”, new Person(“p2”)); hm.put(“C”, new Person(“p3”)); hm.put(“D”, new Person(“p4”)); hm.put(“E”, new Person(“p5”)); Set<Map.Entry<String, Person>> set = hm.entrySet(); for (Map.Entry<String, Person> me : set) { System.out.println(“Key :”+me.getKey() +” Name : “+ me.getValue().getName()+”Age :”+me.getValue().getAge()); }

Convert map[interface {}]interface {} to map[string]string

A secure way to process unknown interfaces, just use fmt.Sprintf() https://play.golang.org/p/gOiyD4KpQGz package main import ( “fmt” ) func main() { mapInterface := make(map[interface{}]interface{}) mapString := make(map[string]string) mapInterface[“k1”] = 1 mapInterface[3] = “hello” mapInterface[“world”] = 1.05 for key, value := range mapInterface { strKey := fmt.Sprintf(“%v”, key) strValue := fmt.Sprintf(“%v”, value) mapString[strKey] = strValue } fmt.Printf(“%#v”, … Read more

Reverse map lookup

There isn’t much you can do about it. Your have options to work with two maps, use multi-key map like one from Boost Multi-Index library, or do linear search. UPDATE: The most lightweight out of the box solution seems to be Boost.Bimap, which stands for bi-directional map.

Rotate MapView in Android

Thanks to pheelicks and Nikita Koksharov answers, I manage to turn on/off the rotation of a mapview according to the compass. First you will need the two inner class of MapViewCompassDemo.java found at: Android_SDK_ Tools\add-ons\addon-google_apis-google-#\samples\MapsDemo\src\com\example\android\apis\view\ RotateView SmoothCanvas Extract the inner class RotateView to RotateView.java and add SmoothCanvas as a inner class of RotateView.java instead of … Read more