public static boolean mergeLTI2Parameters(Properties custom, String customstr) {
		if ( customstr == null || customstr.length() < 1 ) return true;
		JSONArray json = null;
		try {
			json = (JSONArray) JSONValue.parse(customstr.trim());
		} catch(Exception e) {
			M_log.warning("mergeLTI2Parameters could not parse\n"+customstr);
			M_log.warning(e.getLocalizedMessage());
			return false;
		}
		Iterator<?> parameters = json.iterator();
		while( parameters.hasNext() ){
			Object o = parameters.next();
			JSONObject parameter = null;
			try {
				parameter = (JSONObject) o;
			} catch(Exception e) {
				M_log.warning("mergeLTI2Parameters did not find list of objects\n"+customstr);
				M_log.warning(e.getLocalizedMessage());
				return false;
			}

			String name = (String) parameter.get("name");

			if ( name == null ) continue;
			if ( custom.containsKey(name) ) continue;
			String fixed = (String) parameter.get("fixed");
			String variable = (String) parameter.get("variable");
			if ( variable != null ) {
				setProperty(custom, name, variable);
				continue;
			}
			if ( fixed != null ) {
				setProperty(custom, name, fixed);
			}
		}
		return true;
	}
public static boolean mergeLTI2Parameters(Properties custom, String customstr) {
		if ( customstr == null || customstr.length() < 1 ) return true;
		JSONArray json = null;
		try {
			json = (JSONArray) JSONValue.parse(customstr.trim());
		} catch(Exception e) {
			M_log.warning("mergeLTI2Parameters could not parse\n"+customstr);
			M_log.warning(e.getLocalizedMessage());
			return false;
		}
		Iterator<?> parameters = json.iterator();
		while( parameters.hasNext() ){
			Object o = parameters.next();
			JSONObject parameter = null;
			try {
				parameter = (JSONObject) o;
			} catch(Exception e) {
				M_log.warning("mergeLTI2Parameters did not find list of objects\n"+customstr);
				M_log.warning(e.getLocalizedMessage());
				return false;
			}

			String name = (String) parameter.get("name");

			if ( name == null ) continue;
			if ( custom.containsKey(name) ) continue;
			String fixed = (String) parameter.get("fixed");
			String variable = (String) parameter.get("variable");
			if ( variable != null ) {
				setProperty(custom, name, variable);
				continue;
			}
			if ( fixed != null ) {
				setProperty(custom, name, fixed);
			}
		}
		return true;
	}
public static boolean mergeLTI2Parameters ( Properties custom , String customstr ) { if ( customstr == null || customstr . length ( ) < 1 ) return true ; JSONArray json = null ; try { json = ( JSONArray ) JSONValue . parse ( customstr . trim ( ) ) ; } catch ( Exception e ) { M_log . warning ( "mergeLTI2Parameters could not parse\n" + customstr ) ; M_log . warning ( e . getLocalizedMessage ( ) ) ; return false ; } Iterator < ? > parameters = json . iterator ( ) ; while ( parameters . hasNext ( ) ) { Object o = parameters . next ( ) ; JSONObject parameter = null ; try { parameter = ( JSONObject ) o ; } catch ( Exception e ) { M_log . warning ( "mergeLTI2Parameters did not find list of objects\n" + customstr ) ; M_log . warning ( e . getLocalizedMessage ( ) ) ; return false ; } String name = ( String ) parameter . get ( "name" ) ; if ( name == null ) continue ; if ( custom . containsKey ( name ) ) continue ; String fixed = ( String ) parameter . get ( "fixed" ) ; String variable = ( String ) parameter . get ( "variable" ) ; if ( variable != null ) { setProperty ( custom , name , variable ) ; continue ; } if ( fixed != null ) { setProperty ( custom , name , fixed ) ; } } return true ; }
/*
"parameter" :
[
{ "name" : "result_url",
"variable" : "Result.url"
},
{ "name" : "discipline",
"fixed" : "chemistry"
}
]
/ * parameter : [ { name : result_url variable : Result . url } { name : discipline fixed : chemistry } ]