sdk/src/com/socialize/entity/SubscriptionFactory.java
@Override
	protected void postToJSON(Subscription from, JSONObject to) throws JSONException {

		try {
			Entity entityObject = from.getEntity();
			User userObject = from.getUser();
			Long date = from.getDate();
			
			if(entityObject != null) {
				if(!StringUtils.isEmpty(entityObject.getName()) && !StringUtils.isEmpty(entityObject.getKey())) {
					JSONObject entity = entityFactory.toJSON(entityObject);
					to.put("entity", entity);
				}
				else if(!StringUtils.isEmpty(entityObject.getKey())) {
					to.put("entity_key", entityObject.getKey());
				}
			}
			
			if(userObject != null) {
				JSONObject user = userFactory.toJSON(userObject);
				to.put("user", user);
			}
			
			if(date != null) {
				to.put("date", DATE_FORMAT.format(date));
			}
			
			to.put("subscribed", from.isSubscribed());
			to.put("type", from.getNotificationType().name().toLowerCase());
		}
		catch (Exception e) {
			throw new JSONException(e.getMessage());
		}		
	}
@Override
	protected void postToJSON(Subscription from, JSONObject to) throws JSONException {

		try {
			Entity entityObject = from.getEntity();
			User userObject = from.getUser();
			Long date = from.getDate();
			
			if(entityObject != null) {
				if(!StringUtils.isEmpty(entityObject.getName()) && !StringUtils.isEmpty(entityObject.getKey())) {
					JSONObject entity = entityFactory.toJSON(entityObject);
					to.put("entity", entity);
				}
				else if(!StringUtils.isEmpty(entityObject.getKey())) {
					to.put("entity_key", entityObject.getKey());
				}
			}
			
			if(userObject != null) {
				JSONObject user = userFactory.toJSON(userObject);
				to.put("user", user);
			}
			
			if(date != null) {
				to.put("date", DATE_FORMAT.format(date));
			}
			
			to.put("subscribed", from.isSubscribed());
			to.put("type", from.getNotificationType().name().toLowerCase());
		}
		catch (Exception e) {
			throw new JSONException(e.getMessage());
		}		
	}
@ Override protected void postToJSON ( Subscription from , JSONObject to ) throws JSONException { try { Entity entityObject = from . getEntity ( ) ; User userObject = from . getUser ( ) ; Long date = from . getDate ( ) ; if ( entityObject != null ) { if ( ! StringUtils . isEmpty ( entityObject . getName ( ) ) && ! StringUtils . isEmpty ( entityObject . getKey ( ) ) ) { JSONObject entity = entityFactory . toJSON ( entityObject ) ; to . put ( "entity" , entity ) ; } else if ( ! StringUtils . isEmpty ( entityObject . getKey ( ) ) ) { to . put ( "entity_key" , entityObject . getKey ( ) ) ; } } if ( userObject != null ) { JSONObject user = userFactory . toJSON ( userObject ) ; to . put ( "user" , user ) ; } if ( date != null ) { to . put ( "date" , DATE_FORMAT . format ( date ) ) ; } to . put ( "subscribed" , from . isSubscribed ( ) ) ; to . put ( "type" , from . getNotificationType ( ) . name ( ) . toLowerCase ( ) ) ; } catch ( Exception e ) { throw new JSONException ( e . getMessage ( ) ) ; } }
/* (non-Javadoc)
@see com.socialize.entity.SocializeObjectFactory#postToJSON(com.socialize.entity.SocializeObject, org.json.JSONObject)
/ * ( non - Javadoc )