public static FieldValue parseJsonFieldValue(String jsonFieldValue, String fieldPath, DataType fieldType) {
        // Create a dummy document operation to use JSON document parser API.
        // API for parsing individual fields is not exposed.
        var documentTypeName = "dummy"; // avoid built-in name "document".
        var documentId = "id:generate:%s::0".formatted(documentTypeName);
        var jsonDocumentOperation = """
                {
                    "put": "%s",
                    "fields": %s
                }
                """.formatted(documentId, jsonFieldValue);
        
        // Create and register types
        var types = new DocumentTypeManager();
        var docType = new DocumentType(documentTypeName);
        var field = new Field(fieldPath, fieldType);
        docType.addField(field);
        types.registerDocumentType(docType);
        
        // Parse JSON document
        var parserFactory = new JsonFactory();
        var input = new ByteArrayInputStream(Utf8.toBytes(jsonDocumentOperation));
        var jsonReader = new JsonReader(types, input, parserFactory);
        ParsedDocumentOperation parsedDocumentOperation;
        
        try {
            parsedDocumentOperation = jsonReader.readSingleDocumentStreaming(DocumentOperationType.PUT, documentId);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(
                    "Failed to parse JSON value for field %s of type %s: %s"
                            .formatted(fieldPath, fieldType.getName(), jsonFieldValue), e);
        }
        
        var documentOperation = (DocumentPut) parsedDocumentOperation.operation();
        var document = documentOperation.getDocument();
        return document.getFieldValue(field);
    }
Parses JSON containing document field value.
Uses the same parser as the one used during feeding.
model-integration/src/main/java/ai/vespa/llm/generation/FieldGeneratorUtils.java