src/org/ohmage/domain/Document.java
public JSONObject toJsonObject() 
			throws JSONException {

		JSONObject result = new JSONObject();
		
		result.put(JSON_KEY_NAME, name);
		result.put(JSON_KEY_DESCRIPTION, ((description ==  null) ? "" : description));
		result.put(JSON_KEY_PRIVACY_STATE, privacyState);
		result.put(JSON_KEY_LAST_MODIFIED, DateTimeUtils.getIso8601DateString(lastModified, true));
		result.put(JSON_KEY_CREATION_DATE, DateTimeUtils.getIso8601DateString(creationDate, true));
		result.put(JSON_KEY_SIZE, size);
		result.put(JSON_KEY_CREATOR, creator);
		
		result.put(JSON_KEY_USER_ROLE, ((userRole == null) ? "" : userRole));
		result.put(JSON_KEY_CAMPAIGN_ROLE, new JSONObject(campaignAndRole));
		result.put(JSON_KEY_CLASS_ROLE, new JSONObject(classAndRole));
		
		// If the user is an admin, they may not have any role with the 
		// document.
		if(maxRole != null) {
			result.put(JSON_KEY_MAX_ROLE, maxRole.toString());
		}
		
		return result;
	}
/**
	 * Creates a JSONObject representing this document's information.
	 * 
	 * @return A JSONObject representing this document's information.
	 * 
	 * @throws JSONException Thrown if there was an error building the 
	 * 						   JSONObject.
	 */
Creates a JSONObject representing this document's information.

@return A JSONObject representing this document's information.

@throws JSONException Thrown if there was an error building the
JSONObject.
Creates a JSONObject representing this document ' s information . @return A JSONObject representing this document ' s information . @throws JSONException Thrown if there was an error building the JSONObject .
public JSONObject toJsonObject() 
			throws JSONException {
		JSONObject result = new JSONObject();
		result.put(JSON_KEY_NAME, name);
		result.put(JSON_KEY_DESCRIPTION, ((description ==  null) ? "" : description));
		result.put(JSON_KEY_PRIVACY_STATE, privacyState);
		result.put(JSON_KEY_LAST_MODIFIED, DateTimeUtils.getIso8601DateString(lastModified, true));
		result.put(JSON_KEY_CREATION_DATE, DateTimeUtils.getIso8601DateString(creationDate, true));
		result.put(JSON_KEY_SIZE, size);
		result.put(JSON_KEY_CREATOR, creator);
		result.put(JSON_KEY_USER_ROLE, ((userRole == null) ? "" : userRole));
		result.put(JSON_KEY_CAMPAIGN_ROLE, new JSONObject(campaignAndRole));
		result.put(JSON_KEY_CLASS_ROLE, new JSONObject(classAndRole));
		if(maxRole != null) {
			result.put(JSON_KEY_MAX_ROLE, maxRole.toString());
		}
		return result;
	}
public JSONObject toJsonObject ( ) throws JSONException { JSONObject result = new JSONObject ( ) ; result . put ( JSON_KEY_NAME , name ) ; result . put ( JSON_KEY_DESCRIPTION , ( ( description == null ) ? "" : description ) ) ; result . put ( JSON_KEY_PRIVACY_STATE , privacyState ) ; result . put ( JSON_KEY_LAST_MODIFIED , DateTimeUtils . getIso8601DateString ( lastModified , true ) ) ; result . put ( JSON_KEY_CREATION_DATE , DateTimeUtils . getIso8601DateString ( creationDate , true ) ) ; result . put ( JSON_KEY_SIZE , size ) ; result . put ( JSON_KEY_CREATOR , creator ) ; result . put ( JSON_KEY_USER_ROLE , ( ( userRole == null ) ? "" : userRole ) ) ; result . put ( JSON_KEY_CAMPAIGN_ROLE , new JSONObject ( campaignAndRole ) ) ; result . put ( JSON_KEY_CLASS_ROLE , new JSONObject ( classAndRole ) ) ; if ( maxRole != null ) { result . put ( JSON_KEY_MAX_ROLE , maxRole . toString ( ) ) ; } return result ; }
Creates a JSONObject representing this document's information.
Creates a JSONObject representing this document ' s information .
// If the user is an admin, they may not have any role with the  // document.