public static JsonSchemaNode createSchema ( JsonParser parser ) throws IOException { JsonSchemaNode dummy = new JsonSchemaStructNode ( null ) ; JsonSchemaStructNode parent = ( JsonSchemaStructNode ) dummy ; JsonToken currentToken = parser . nextToken ( ) ; int nameLocation = - 1 ; if ( currentToken == null ) { return null ; } while ( currentToken != null ) { if ( currentToken . isStructStart ( ) ) { JsonSchemaStructNode structNode = new JsonSchemaStructNode ( parent ) ; JsonSchemaNameValue nameValue = new JsonSchemaNameValue ( nameLocation , structNode ) ; parent . addChild ( nameValue ) ; parent = structNode ; nameLocation = - 1 ; } else if ( currentToken == JsonToken . FIELD_NAME ) { nameLocation = ( int ) getTokenLocation ( parser ) ; } else if ( currentToken . isStructEnd ( ) ) { parent = parent . getParent ( ) ; nameLocation = - 1 ; } else { JsonSchemaTerminalNode terminalNode = new JsonSchemaTerminalNode ( parent ) ; terminalNode . setValueStartLocation ( ( int ) getTokenLocation ( parser ) ) ; JsonSchemaNameValue nameValue = new JsonSchemaNameValue ( nameLocation , terminalNode ) ; parent . addChild ( nameValue ) ; nameLocation = - 1 ; } currentToken = parser . nextToken ( ) ; } JsonSchemaNameValue nameValue = ( ( JsonSchemaStructNode ) dummy ) . getChild ( 0 ) ; if ( nameValue == null ) { return null ; } dummy = nameValue . getValue ( ) ; dummy . setParent ( null ) ; return dummy ; }
Creates a description out of a JsonValue . The parser must be pointing to the start of the input .