protected void parse ( String json ) { logger . entering ( json ) ; try { Gson gson = new Gson ( ) ; BaseLog baseLog = gson . fromJson ( json , this . getClass ( ) ) ; this . msg = baseLog . msg ; this . screen = baseLog . screen ; this . location = baseLog . location ; this . href = baseLog . href ; } catch ( JsonSyntaxException e ) { // If not JSON string then treat this as an message this . msg = json ; } logger . exiting ( ) ; }
Parsing the JSON string using Gson library .