Skip to content

JsonPath example(s) missing in README.md #81

Open
@koppor

Description

@koppor

I crafted following code to get a String from a JSON component.

            JsonNode json = JsonNode.of(response);
            JsonNode disclaimerJson = json.getOrNull("citingPaperInfo.openAccessPdf.disclaimer");
            if (disclaimerJson != null) {
                JsonMixed disclaimerNode = JsonMixed.of(disclaimerJson);
                if (disclaimerNode.isString()) {
                    String disclaimer = disclaimerNode.string();

It seems very complex. I wonder if there is an easier method.

I would have json.getOrNull("citingPaperInfo.openAccessPdf.disclaimer").string(), but that will be an NPE 😅. Optionals would be great

json.getOptional("citingPaperInfo.openAccessPdf.disclaimer").map(::string) (or similar)

(Full code changes: JabRef/jabref#13549)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions