private List<FieldValues> parseResponse(final JsonNode response) {
        if (response == null || response.get("fields") == null) {
            throw new RuntimeException("Failed to parse JSON");
        }

        final JsonNode fieldsNode = response.get("fields");

        if (fieldsNode.getNodeType() == JsonNodeType.OBJECT || fieldsNode.getNodeType() == JsonNodeType.ARRAY) {
            final List<FieldValues> output = new ArrayList<>();

            for (final JsonNode node : fieldsNode) {
                try {
                    final FieldValues fieldValues = objectMapper.treeToValue(node, FieldValues.class);
                    output.add(fieldValues);
                } catch (final JsonProcessingException e) {
                    throw new RuntimeException("Failed to parse JSON", e);
                }
            }

            return output;
        } else {
            throw new RuntimeException("Failed to parse JSON");
        }
    }
private List<FieldValues> parseResponse(final JsonNode response) {
        if (response == null || response.get("fields") == null) {
            throw new RuntimeException("Failed to parse JSON");
        }

        final JsonNode fieldsNode = response.get("fields");

        if (fieldsNode.getNodeType() == JsonNodeType.OBJECT || fieldsNode.getNodeType() == JsonNodeType.ARRAY) {
            final List<FieldValues> output = new ArrayList<>();

            for (final JsonNode node : fieldsNode) {
                try {
                    final FieldValues fieldValues = objectMapper.treeToValue(node, FieldValues.class);
                    output.add(fieldValues);
                } catch (final JsonProcessingException e) {
                    throw new RuntimeException("Failed to parse JSON", e);
                }
            }

            return output;
        } else {
            throw new RuntimeException("Failed to parse JSON");
        }
    }
private List < FieldValues > parseResponse ( final JsonNode response ) { if ( response == null || response . get ( "fields" ) == null ) { throw new RuntimeException ( "Failed to parse JSON" ) ; } final JsonNode fieldsNode = response . get ( "fields" ) ; if ( fieldsNode . getNodeType ( ) == JsonNodeType . OBJECT || fieldsNode . getNodeType ( ) == JsonNodeType . ARRAY ) { final List < FieldValues > output = new ArrayList <> ( ) ; for ( final JsonNode node : fieldsNode ) { try { final FieldValues fieldValues = objectMapper . treeToValue ( node , FieldValues . class ) ; output . add ( fieldValues ) ; } catch ( final JsonProcessingException e ) { throw new RuntimeException ( "Failed to parse JSON" , e ) ; } } return output ; } else { throw new RuntimeException ( "Failed to parse JSON" ) ; } }
/*
HOD has a bug (HOD-5731) where, if a query profile is provided, GetParametricValues returns an object with number
keys rather than an array. This parses a JSON node of either type.
/ * HOD has a bug ( HOD - 5731 ) where if a query profile is provided GetParametricValues returns an object with number keys rather than an array . This parses a JSON node of either type .