src/main/java/org/imsglobal/lti2/LTI2Util.java
public static boolean mergeLTI2Custom(Properties custom, String customstr) 
	{
		if ( customstr == null || customstr.length() < 1 ) return true;
		JSONObject json = null;
		try {
			json = (JSONObject) JSONValue.parse(customstr.trim());
		} catch(Exception e) {
			M_log.warning("mergeLTI2Custom could not parse\n"+customstr);
			M_log.warning(e.getLocalizedMessage());
			return false;
		}

		// This could happen if the old settings service was used
		// on an LTI 2.x placement to put in settings that are not
		// JSON - we just ignore it.
		if ( json == null ) return false;
		Iterator<?> keys = json.keySet().iterator();
		while( keys.hasNext() ){
			String key = (String)keys.next();
			if ( custom.containsKey(key) ) continue;
			Object value = json.get(key);
			if ( value instanceof String ){
				setProperty(custom, key, (String) value);
			}
		}
		return true;
	}
public static boolean mergeLTI2Custom(Properties custom, String customstr) 
	{
		if ( customstr == null || customstr.length() < 1 ) return true;
		JSONObject json = null;
		try {
			json = (JSONObject) JSONValue.parse(customstr.trim());
		} catch(Exception e) {
			M_log.warning("mergeLTI2Custom could not parse\n"+customstr);
			M_log.warning(e.getLocalizedMessage());
			return false;
		}

		// This could happen if the old settings service was used
		// on an LTI 2.x placement to put in settings that are not
		// JSON - we just ignore it.
		if ( json == null ) return false;
		Iterator<?> keys = json.keySet().iterator();
		while( keys.hasNext() ){
			String key = (String)keys.next();
			if ( custom.containsKey(key) ) continue;
			Object value = json.get(key);
			if ( value instanceof String ){
				setProperty(custom, key, (String) value);
			}
		}
		return true;
	}
public static boolean mergeLTI2Custom ( Properties custom , String customstr ) { if ( customstr == null || customstr . length ( ) < 1 ) return true ; JSONObject json = null ; try { json = ( JSONObject ) JSONValue . parse ( customstr . trim ( ) ) ; } catch ( Exception e ) { M_log . warning ( "mergeLTI2Custom could not parse\n" + customstr ) ; M_log . warning ( e . getLocalizedMessage ( ) ) ; return false ; } // This could happen if the old settings service was used // on an LTI 2.x placement to put in settings that are not // JSON - we just ignore it. if ( json == null ) return false ; Iterator < ? > keys = json . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { String key = ( String ) keys . next ( ) ; if ( custom . containsKey ( key ) ) continue ; Object value = json . get ( key ) ; if ( value instanceof String ) { setProperty ( custom , key , ( String ) value ) ; } } return true ; }
/*
"custom" :
{
"isbn" : "978-0321558145",
"style" : "jazzy"
}
/ * custom : { isbn : 978 - 0321558145 style : jazzy }