public static JSONObject serializeToJson(final SerializableEntity entity){
  final JsonSerializer serializer=new JsonSerializer();
  entity.serialize(serializer);
  return serializer.getObject();
}

public static JSONObject serializeToJson ( final SerializableEntity entity ) { final JsonSerializer serializer = new JsonSerializer ( ) ; entity . serialize ( serializer ) ; return serializer . getObject ( ) ; }
helper function that serializes a serializableentity to a json object .
