class SpannableSerializer {

    public static String serializeSpannableString(final SpannableString ss) {
        val json = new JSONObject();
        try {
            json.put("mText", ss.toString());
            json.put("bgc", extractClass(ss, BackgroundColorSpan.class));
            json.put("fgc", extractClass(ss, ForegroundColorSpan.class));

        } catch (JSONException e) {
            // we're done for if we hit here
        }
        return json.toString();
    }

}