Buggy code:
public class JsonLDManager { public String currentNPSet ; public String currentDeviceManagerPayload ; public String semanticsSolutionsFilePath ; public String mappingRulesFilePath ; public String mmInput ; public String preprocessingTempfilePath ; public String postprocessingTempfilePath ; public Gson gson ; private static JsonLDManager instance = null ; private JsonLDManager ( ) { } public static JsonLDManager getInstance ( ) { } public void runJSONLDTests ( ) { } public Model inferConfiguration ( Model model , String ruleFile ) { } public void createMMoutput ( Model model ) { } private void runQuery ( String queryRequest , Model model ) { } private void preprocessing ( String in ) throws IOException , URISyntaxException , JSONException { String inputString = JsonLDManager . readFile ( in , StandardCharsets . UTF_8 ) ; JSONTokener inputTokener = new JSONTokener ( inputString ) ; JSONObject mmIn = new JSONObject ( inputTokener ) ; JSONObject outPreProc = new JSONObject ( ) ; JSONObject outContext = new JSONObject ( ) ; JSONArray outGraph = new JSONArray ( ) ; if ( mmIn . has ( "preferences" ) ) { JSONObject inContext = mmIn . getJSONObject ( "preferences" ) . getJSONObject ( "contexts" ) ; Iterator < ? > cKeys = inContext . keys ( ) ; while ( cKeys . hasNext ( ) ) { String cID = ( ( String ) ( cKeys . next ( ) ) ) ; String cName = inContext . getJSONObject ( cID ) . get ( "name" ) . toString ( ) ; JSONObject cPrefs = inContext . getJSONObject ( cID ) . getJSONObject ( "preferences" ) ; JSONObject outPrefSet = new JSONObject ( ) ; outPrefSet . put ( "@id" , ( "c4a:" + cID ) ) ; outPrefSet . put ( "@type" , "c4a:PreferenceSet" ) ; outPrefSet . put ( "c4a:id" , cID ) ; outPrefSet . put ( "c4a:name" , cName ) ; JSONArray outPrefArray = new JSONArray ( ) ; Iterator < ? > pKeys = cPrefs . keys ( ) ; while ( pKeys . hasNext ( ) ) { String pID = ( ( String ) ( pKeys . next ( ) ) ) ; String pVal = cPrefs . getString ( pID ) ; JSONObject outPref = new JSONObject ( ) ; <START_BUG> outPref . put ( "@id" , pID ) ; <END_BUG> outPref . put ( "@type" , "c4a:Preference" ) ; if ( pID . contains ( "common" ) ) outPref . put ( "c4a:type" , "common" ) ; if ( pID . contains ( "applications" ) ) outPref . put ( "c4a:type" , "application" ) ; URI uri = new URI ( pID ) ; String path = uri . getPath ( ) ; String idStr = path . substring ( ( ( path . lastIndexOf ( '//' ) ) + 1 ) ) ; outPref . put ( "c4a:name" , idStr ) ; outPref . put ( "c4a:value" , pVal ) ; outPrefArray . put ( outPref ) ; } outPrefSet . put ( "c4a:hasPrefs" , outPrefArray ) ; outGraph . put ( outPrefSet ) ; } } if ( mmIn . has ( "deviceReporter" ) ) { JSONObject inDevice = mmIn . getJSONObject ( "deviceReporter" ) ; if ( inDevice . has ( "OS" ) ) { JSONObject inOS = inDevice . getJSONObject ( "OS" ) ; String osID = inOS . get ( "id" ) . toString ( ) ; String osVer = inOS . get ( "version" ) . toString ( ) ; JSONObject outOS = new JSONObject ( ) ; outOS . put ( "@type" , "c4a:OperatingSystem" ) ; outOS . put ( "@id" , ( "c4a:" + osID ) ) ; outOS . put ( "name" , osID ) ; outOS . put ( "version" , osVer ) ; outGraph . put ( outOS ) ; } if ( inDevice . has ( "solutions" ) ) { JSONArray inSol = inDevice . getJSONArray ( "solutions" ) ; for ( int i = 0 ; i < ( inSol . length ( ) ) ; i ++ ) { String solID = inSol . getJSONObject ( i ) . get ( "id" ) . toString ( ) ; JSONObject outSol = new JSONObject ( ) ; outSol . put ( "@type" , "c4a:InstalledSolution" ) ; outSol . put ( "@id" , ( "c4a:" + solID ) ) ; outSol . put ( "name" , solID ) ; outGraph . put ( outSol ) ; } } } outContext . put ( "c4a" , "http:////rbmm.org//schemas//cloud4all//0.1//" ) ; outContext . put ( "rdfs" , "http:////www.w3.org//2000//01//rdf-schema#" ) ; outPreProc . put ( "@context" , outContext ) ; outPreProc . put ( "@graph" , outGraph ) ; byte [ ] dataToWrite = outPreProc . toString ( ) . getBytes ( StandardCharsets . US_ASCII ) ; writeFile ( preprocessingTempfilePath , dataToWrite ) ; } private void writeFile ( String path , byte [ ] dataToWrite ) { } static String readFile ( String path , Charset encoding ) throws IOException { } No newline ; at end ; of file ; }

Fix:
outPref . put ( "c4a:id" , pID ) ;