public static Object getElement ( final JsonNode json , final String name ) { if ( json != null && name != null ) { JsonNode node = json ; for ( String nodeName : name . split ( "\\." ) ) { if ( node != null ) { if ( nodeName . matches ( "\\d+" ) ) { node = node . get ( Integer . parseInt ( nodeName ) ) ; } else { node = node . get ( nodeName ) ; } } } if ( node != null ) { if ( node . isNumber ( ) ) { return node . numberValue ( ) ; } else if ( node . isBoolean ( ) ) { return node . booleanValue ( ) ; } else if ( node . isTextual ( ) ) { return node . textValue ( ) ; } else if ( node . isNull ( ) ) { return null ; } else { return node ; } } } return null ; }
Return the field with name in JSON as a string a boolean a number or a node .