public Correspondence convert ( JSONObject jResponse ) throws JSONException { Correspondence correspondence = null ; if ( jResponse . getJSONObject ( "response" ) . has ( "Correspondence" ) ) { JSONObject jResponseItem = jResponse . getJSONObject ( "response" ) ; JSONArray jcorrespondenceItems = jResponseItem . getJSONArray ( "Correspondence" ) ; List < CorrespondenceItem > correspondenceItems = new ArrayList < CorrespondenceItem > ( ) ; for ( int i = 0 ; i < jcorrespondenceItems . length ( ) ; i ++ ) { JSONObject jCorrespondenceItem = jcorrespondenceItems . getJSONObject ( i ) ; String relation = jCorrespondenceItem . optString ( "Relation" ) ; String source = jCorrespondenceItem . optString ( "Source" ) ; String target = jCorrespondenceItem . optString ( "Target" ) ; char cRelation = relation . charAt ( 0 ) ; try { correspondenceItems . add ( new CorrespondenceItem ( source , target , cRelation ) ) ; } catch ( UnknownRelationException ex ) { Logger . getLogger ( MatchMethods . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } } correspondence = new Correspondence ( correspondenceItems ) ; } return correspondence ; }
Converts from JSON Correspondence to Java Correspondence