src/org/ohmage/domain/UserInformation.java
public JSONObject toJson(
			final boolean withUsername,
			final boolean withPersonal) 
			throws JSONException {
		
		JSONObject result = new JSONObject();

		if(withUsername) {
			result.put(UserColumnKey.USERNAME.toString(), username);
		}

		result.put(UserColumnKey.EMAIL_ADDRESS.toString(), emailAddress);

		JSONObject permissionsJson = new JSONObject();
		permissionsJson.put(UserPermissionColumnKey.ADMIN.toString(), isAdmin);
		permissionsJson.put(
			UserPermissionColumnKey.ENABLED.toString(),
			isEnabled);
		permissionsJson.put(
			UserPermissionColumnKey.NEW_ACCOUNT.toString(),
			isNewAccount);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_CREATE_CAMPAIGNS.toString(),
			campaignCreationPrivilege);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_CREATE_CLASSES.toString(),
			classCreationPrivilege);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_SETUP_USERS.toString(),
			userSetupPrivilege);
		result.put(UserColumnKey.PERMISSIONS.toString(), permissionsJson);

		if(campaigns != null) {
			result.put(UserColumnKey.CAMPAIGNS.toString(), campaigns);
		}
		if(classes != null) {
			result.put(UserColumnKey.CLASSES.toString(), classes);
		}

		if((personalInfo != null) && withPersonal) {
			result.put(
				UserColumnKey.PERSONAL.toString(),
				personalInfo.toJsonObject());
		}

		return result;
	}
/**
	 * Serializes the user's information object.
	 * 
	 * @return A JSONObject representing this user information.
	 * 
	 * @throws JSONException Thrown if there is a problem building the JSON.
	 */
Serializes the user's information object.

@return A JSONObject representing this user information.

@throws JSONException Thrown if there is a problem building the JSON.
Serializes the user ' s information object . @return A JSONObject representing this user information . @throws JSONException Thrown if there is a problem building the JSON .
public JSONObject toJson(
			final boolean withUsername,
			final boolean withPersonal) 
			throws JSONException {
		JSONObject result = new JSONObject();
		if(withUsername) {
			result.put(UserColumnKey.USERNAME.toString(), username);
		}
		result.put(UserColumnKey.EMAIL_ADDRESS.toString(), emailAddress);
		JSONObject permissionsJson = new JSONObject();
		permissionsJson.put(UserPermissionColumnKey.ADMIN.toString(), isAdmin);
		permissionsJson.put(
			UserPermissionColumnKey.ENABLED.toString(),
			isEnabled);
		permissionsJson.put(
			UserPermissionColumnKey.NEW_ACCOUNT.toString(),
			isNewAccount);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_CREATE_CAMPAIGNS.toString(),
			campaignCreationPrivilege);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_CREATE_CLASSES.toString(),
			classCreationPrivilege);
		permissionsJson.put(
			UserPermissionColumnKey.CAN_SETUP_USERS.toString(),
			userSetupPrivilege);
		result.put(UserColumnKey.PERMISSIONS.toString(), permissionsJson);
		if(campaigns != null) {
			result.put(UserColumnKey.CAMPAIGNS.toString(), campaigns);
		}
		if(classes != null) {
			result.put(UserColumnKey.CLASSES.toString(), classes);
		}
		if((personalInfo != null) && withPersonal) {
			result.put(
				UserColumnKey.PERSONAL.toString(),
				personalInfo.toJsonObject());
		}
		return result;
	}
public JSONObject toJson ( final boolean withUsername , final boolean withPersonal ) throws JSONException { JSONObject result = new JSONObject ( ) ; if ( withUsername ) { result . put ( UserColumnKey . USERNAME . toString ( ) , username ) ; } result . put ( UserColumnKey . EMAIL_ADDRESS . toString ( ) , emailAddress ) ; JSONObject permissionsJson = new JSONObject ( ) ; permissionsJson . put ( UserPermissionColumnKey . ADMIN . toString ( ) , isAdmin ) ; permissionsJson . put ( UserPermissionColumnKey . ENABLED . toString ( ) , isEnabled ) ; permissionsJson . put ( UserPermissionColumnKey . NEW_ACCOUNT . toString ( ) , isNewAccount ) ; permissionsJson . put ( UserPermissionColumnKey . CAN_CREATE_CAMPAIGNS . toString ( ) , campaignCreationPrivilege ) ; permissionsJson . put ( UserPermissionColumnKey . CAN_CREATE_CLASSES . toString ( ) , classCreationPrivilege ) ; permissionsJson . put ( UserPermissionColumnKey . CAN_SETUP_USERS . toString ( ) , userSetupPrivilege ) ; result . put ( UserColumnKey . PERMISSIONS . toString ( ) , permissionsJson ) ; if ( campaigns != null ) { result . put ( UserColumnKey . CAMPAIGNS . toString ( ) , campaigns ) ; } if ( classes != null ) { result . put ( UserColumnKey . CLASSES . toString ( ) , classes ) ; } if ( ( personalInfo != null ) && withPersonal ) { result . put ( UserColumnKey . PERSONAL . toString ( ) , personalInfo . toJsonObject ( ) ) ; } return result ; }
Serializes the user's information object.
Serializes the user ' s information object .