@ Override public boolean process ( Namespace ns ) { boolean suppressOutput = ns . getBoolean ( "s" ) ; Object jsonObject1 = JoltCliUtilities . createJsonObjectFromFile ( ( File ) ns . get ( "filePath1" ) , suppressOutput ) ; File file = ns . get ( "filePath2" ) ; Object jsonObject2 = JoltCliUtilities . readJsonInput ( file , suppressOutput ) ; Diffy diffy ; if ( ns . getBoolean ( "a" ) ) { diffy = new ArrayOrderObliviousDiffy ( ) ; } else { diffy = new Diffy ( ) ; } Diffy . Result result = diffy . diff ( jsonObject1 , jsonObject2 ) ; if ( result . isEmpty ( ) ) { JoltCliUtilities . printToStandardOut ( "Diffy found no differences" , suppressOutput ) ; return true ; } else { try { JoltCliUtilities . printToStandardOut ( "Differences found. Input #1 contained this:\n" + JsonUtils . toPrettyJsonString ( result . expected ) + "\n" + "Input #2 contained this:\n" + JsonUtils . toPrettyJsonString ( result . actual ) , suppressOutput ) ; } catch ( Exception e ) { JoltCliUtilities . printToStandardOut ( "Differences found, but diffy encountered an error while writing the result." , suppressOutput ) ; } return false ; } }
Process the Diffy Subcommand