public void toJSON(Object obj, Output out) { if (_fromJSON) { out.addClass(obj.getClass()); out.add("value", ((Enum) obj).name()); } else { out.add(((Enum) obj).name()); } }
public void toJSON(Object obj, Output out) { if (_fromJSON) { out.addClass(obj.getClass()); out.add("value", obj.toString()); } else { out.add(obj.toString()); } }
/* ------------------------------------------------------------ */ public void toJSON(Object obj, Output out) { if (_fromJSON) out.addClass(_pojoClass); for (Map.Entry<String, Method> entry : _getters.entrySet()) { try { out.add(entry.getKey(), entry.getValue().invoke(obj, GETTER_ARG)); } catch (Exception e) { // TODO throw exception? LOG.warn("{} property '{}' excluded. (errors)", _pojoClass.getName(), entry.getKey()); log(e); } } }
@Override public void toJSON(Object arg0, Output arg1) { if (arg0 == null) { arg1.add(null); return; } TokenizedField tf = (TokenizedField) arg0; arg1.add(FieldNameTag, tf.getFieldName()); arg1.add(TermsTag, tf.getTerms()); arg1.add(TFScoresTag, tf.getTF()); arg1.add(FieldIsPublicTag, tf.isPublic()); }
public void toJSON(Output out) { out.addClass(Woggle.class); out.add("name", name); out.add("nested", nested); out.add("number", number); }