@Test public void testToJSONAttrs() { user = new LQUser("123", attrs); JSONObject json = user.toJSON(); assertTrue(json.has("unique_id")); assertTrue(json.has("teste1")); assertTrue(json.has("teste2")); assertTrue(json.has("teste3")); }
public JSONObject toJSON() { JSONObject json = new JSONObject(); try { if(mAttributes != null) { for(String key : mAttributes.keySet()) { if(mAttributes.get(key) instanceof Date) { json.put(key, LiquidTools.dateToString((Date) mAttributes.get(key))); } else { json.put(key, mAttributes.get(key)); } } } json.put("unique_id", mIdentifier); json.put("identified", mIdentified); return json; } catch (JSONException e) { LQLog.error("LQUser toJSON: " + e.getMessage()); } return null; }
LQUser extends LQModel { public JSONObject toJSON() { JSONObject json = new JSONObject(); try { if(mAttributes != null) { for(String key : mAttributes.keySet()) { if(mAttributes.get(key) instanceof Date) { json.put(key, LiquidTools.dateToString((Date) mAttributes.get(key))); } else { json.put(key, mAttributes.get(key)); } } } json.put("unique_id", mIdentifier); json.put("identified", mIdentified); return json; } catch (JSONException e) { LQLog.error("LQUser toJSON: " + e.getMessage()); } return null; } }
LQUser extends LQModel { public JSONObject toJSON() { JSONObject json = new JSONObject(); try { if(mAttributes != null) { for(String key : mAttributes.keySet()) { if(mAttributes.get(key) instanceof Date) { json.put(key, LiquidTools.dateToString((Date) mAttributes.get(key))); } else { json.put(key, mAttributes.get(key)); } } } json.put("unique_id", mIdentifier); json.put("identified", mIdentified); return json; } catch (JSONException e) { LQLog.error("LQUser toJSON: " + e.getMessage()); } return null; } LQUser(String identifier);  LQUser(String identifier, boolean identified);  LQUser(String identifier, HashMap<String, Object> attributes);  LQUser(String identifier, HashMap<String, Object> attributes, boolean identified); }
LQUser extends LQModel { public JSONObject toJSON() { JSONObject json = new JSONObject(); try { if(mAttributes != null) { for(String key : mAttributes.keySet()) { if(mAttributes.get(key) instanceof Date) { json.put(key, LiquidTools.dateToString((Date) mAttributes.get(key))); } else { json.put(key, mAttributes.get(key)); } } } json.put("unique_id", mIdentifier); json.put("identified", mIdentified); return json; } catch (JSONException e) { LQLog.error("LQUser toJSON: " + e.getMessage()); } return null; } LQUser(String identifier);  LQUser(String identifier, boolean identified);  LQUser(String identifier, HashMap<String, Object> attributes);  LQUser(String identifier, HashMap<String, Object> attributes, boolean identified); String getIdentifier(); String setIdentifierForPrefs(String identifier); boolean isIdentified(); void setIdentified(boolean mAutoIdentified); @Override boolean equals(Object o); void clearCustomAttributes(); HashMap<String, Object> getAttributes(); void setAttributes(HashMap<String, Object> attributes); Object setAttribute(String key, Object attribute); Object attributeForKey(String key); JSONObject toJSON(); static LQModel fromJSON(JSONObject jsonObject); @Override void save(Context context, String path); static LQUser load(Context context, String path); }
LQUser extends LQModel { public JSONObject toJSON() { JSONObject json = new JSONObject(); try { if(mAttributes != null) { for(String key : mAttributes.keySet()) { if(mAttributes.get(key) instanceof Date) { json.put(key, LiquidTools.dateToString((Date) mAttributes.get(key))); } else { json.put(key, mAttributes.get(key)); } } } json.put("unique_id", mIdentifier); json.put("identified", mIdentified); return json; } catch (JSONException e) { LQLog.error("LQUser toJSON: " + e.getMessage()); } return null; } LQUser(String identifier);  LQUser(String identifier, boolean identified);  LQUser(String identifier, HashMap<String, Object> attributes);  LQUser(String identifier, HashMap<String, Object> attributes, boolean identified); String getIdentifier(); String setIdentifierForPrefs(String identifier); boolean isIdentified(); void setIdentified(boolean mAutoIdentified); @Override boolean equals(Object o); void clearCustomAttributes(); HashMap<String, Object> getAttributes(); void setAttributes(HashMap<String, Object> attributes); Object setAttribute(String key, Object attribute); Object attributeForKey(String key); JSONObject toJSON(); static LQModel fromJSON(JSONObject jsonObject); @Override void save(Context context, String path); static LQUser load(Context context, String path);  }