How to write a custom JSON decoder for a complex object?

The encoder/decoder example you reference (here) could be easily extended to allow different types of objects in the JSON input/output. However, if you just want a simple decoder to match your encoder (only having Edge objects encoded in your JSON file), use this decoder: class EdgeDecoder(json.JSONDecoder): def __init__(self, *args, **kwargs): json.JSONDecoder.__init__(self, object_hook=self.object_hook, *args, **kwargs) def … Read more

Base64 encoder and decoder

This is an example of how to use the Base64 class to encode and decode a simple String value. // String to be encoded with Base64 String text = “Test”; // Sending side byte[] data = null; try { data = text.getBytes(“UTF-8”); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } String base64 = Base64.encodeToString(data, Base64.DEFAULT); // … Read more