private static Map<String, Object> serializePrimitive(Object primitive) {
        Map<String, Object> data = new HashMap<String, Object>();
        if (primitive instanceof Integer)
            data.put("T", "I");
        else if (primitive instanceof Long)
            data.put("T", "J");
        else if (primitive instanceof Float)
            data.put("T", "F");
        else if (primitive instanceof Double)
            data.put("T", "D");
        else if (primitive instanceof Boolean)
            data.put("T", "Z");
        else if (primitive instanceof Character)
            data.put("T", "C");
        else if (primitive instanceof Byte)
            data.put("T", "B");
        else if (primitive instanceof Short)
            data.put("T", "S");
        else
            throw new RuntimeException("attempt to serialize " + primitive.getClass().getName() + " as primitive");
        data.put("value", primitive);
        return data;
    }