src/main/java/sancus/service/ContractOntologyService.java
public void JsonContractToJavaObject(String contractInJSON) {
//		contractAntlrFormat = contractJsonObject("./Contracts/test7.sol");
		contractAntlrFormat = contractJsonObject(contractInJSON);
		System.out.println(contractAntlrFormat);
		JsonArray contractArray = contractAntlrFormat.get("sourceUnit").getAsJsonArray();
		for(int i = 0; i < contractArray.size(); i++) {
			JsonObject contractI = contractArray.get(i).getAsJsonObject();
			String keyArray = contractI.keySet().iterator().next();
			if(keyArray.contentEquals("pragmaDirective")) {
				implementationSpecification.setVersion(solidityVersion(contractI.get(keyArray).getAsJsonArray()));
			}
			if(keyArray.contentEquals("contractDefinition")) {
				implementationSpecification.setHasContractName(solidityContract(contractI.get("contractDefinition").getAsJsonArray()));
				solidityAttributes(contractI.get("contractDefinition").getAsJsonArray());
				solidityConstructor(contractI.get("contractDefinition").getAsJsonArray());
				solidityFunctions(contractI.get("contractDefinition").getAsJsonArray());
				solidityModifiers(contractI.get("contractDefinition").getAsJsonArray());
				solidityEvents(contractI.get("contractDefinition").getAsJsonArray());
			}
		}
		contractSpecification.setHasAttributes(attributeSpecificationList);
		contractSpecification.setHasConstructor(constructorSpecification);
		contractSpecification.setHasFunctions(functionSpecificationList);
		contractSpecification.setHasModifier(modifierSpecificationList);
		contractSpecification.setHasEvents(eventSpecificationList);
		implementationSpecification.setContractSpecification(contractSpecification);
		globalContractSpecification.setGlobalContract(implementationSpecification);
		ObjectMapper mapper = new ObjectMapper();
		try {
			String json = mapper.setSerializationInclusion(Include.NON_NULL).setSerializationInclusion(Include.NON_EMPTY).writeValueAsString(globalContractSpecification);
			System.out.println(json);
		}catch (JsonProcessingException e) {
			e.printStackTrace();
		}
	}
/**
	 * Main function. Parse JSON to Java Objects
	 * @param contractInJSON
	 */
Main function. Parse JSON to Java Objects
@param contractInJSON
Main function . Parse JSON to Java Objects @param contractInJSON
public void JsonContractToJavaObject(String contractInJSON) {
		contractAntlrFormat = contractJsonObject(contractInJSON);
		System.out.println(contractAntlrFormat);
		JsonArray contractArray = contractAntlrFormat.get("sourceUnit").getAsJsonArray();
		for(int i = 0; i < contractArray.size(); i++) {
			JsonObject contractI = contractArray.get(i).getAsJsonObject();
			String keyArray = contractI.keySet().iterator().next();
			if(keyArray.contentEquals("pragmaDirective")) {
				implementationSpecification.setVersion(solidityVersion(contractI.get(keyArray).getAsJsonArray()));
			}
			if(keyArray.contentEquals("contractDefinition")) {
				implementationSpecification.setHasContractName(solidityContract(contractI.get("contractDefinition").getAsJsonArray()));
				solidityAttributes(contractI.get("contractDefinition").getAsJsonArray());
				solidityConstructor(contractI.get("contractDefinition").getAsJsonArray());
				solidityFunctions(contractI.get("contractDefinition").getAsJsonArray());
				solidityModifiers(contractI.get("contractDefinition").getAsJsonArray());
				solidityEvents(contractI.get("contractDefinition").getAsJsonArray());
			}
		}
		contractSpecification.setHasAttributes(attributeSpecificationList);
		contractSpecification.setHasConstructor(constructorSpecification);
		contractSpecification.setHasFunctions(functionSpecificationList);
		contractSpecification.setHasModifier(modifierSpecificationList);
		contractSpecification.setHasEvents(eventSpecificationList);
		implementationSpecification.setContractSpecification(contractSpecification);
		globalContractSpecification.setGlobalContract(implementationSpecification);
		ObjectMapper mapper = new ObjectMapper();
		try {
			String json = mapper.setSerializationInclusion(Include.NON_NULL).setSerializationInclusion(Include.NON_EMPTY).writeValueAsString(globalContractSpecification);
			System.out.println(json);
		}catch (JsonProcessingException e) {
			e.printStackTrace();
		}
	}
public void JsonContractToJavaObject ( String contractInJSON ) { contractAntlrFormat = contractJsonObject ( contractInJSON ) ; System . out . println ( contractAntlrFormat ) ; JsonArray contractArray = contractAntlrFormat . get ( "sourceUnit" ) . getAsJsonArray ( ) ; for ( int i = 0 ; i < contractArray . size ( ) ; i ++ ) { JsonObject contractI = contractArray . get ( i ) . getAsJsonObject ( ) ; String keyArray = contractI . keySet ( ) . iterator ( ) . next ( ) ; if ( keyArray . contentEquals ( "pragmaDirective" ) ) { implementationSpecification . setVersion ( solidityVersion ( contractI . get ( keyArray ) . getAsJsonArray ( ) ) ) ; } if ( keyArray . contentEquals ( "contractDefinition" ) ) { implementationSpecification . setHasContractName ( solidityContract ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ) ; solidityAttributes ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ; solidityConstructor ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ; solidityFunctions ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ; solidityModifiers ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ; solidityEvents ( contractI . get ( "contractDefinition" ) . getAsJsonArray ( ) ) ; } } contractSpecification . setHasAttributes ( attributeSpecificationList ) ; contractSpecification . setHasConstructor ( constructorSpecification ) ; contractSpecification . setHasFunctions ( functionSpecificationList ) ; contractSpecification . setHasModifier ( modifierSpecificationList ) ; contractSpecification . setHasEvents ( eventSpecificationList ) ; implementationSpecification . setContractSpecification ( contractSpecification ) ; globalContractSpecification . setGlobalContract ( implementationSpecification ) ; ObjectMapper mapper = new ObjectMapper ( ) ; try { String json = mapper . setSerializationInclusion ( Include . NON_NULL ) . setSerializationInclusion ( Include . NON_EMPTY ) . writeValueAsString ( globalContractSpecification ) ; System . out . println ( json ) ; } catch ( JsonProcessingException e ) { e . printStackTrace ( ) ; } }
Main function.
Main function .
//		contractAntlrFormat = contractJsonObject("./Contracts/test7.sol");