Skip to content

Feature request: Allow json_transforms prior to json_path or image_url_path usage. #126

@w8HAQRHkTx7r

Description

@w8HAQRHkTx7r

I have experimented with initializing a PyPortal object using json_transform=(myTransform),. Based on debug print statements, the transform function I wrote seems to be called after the .fetch() method has completed (or at least at the very end of the .fetch() method). I want to be able to edit (transform) the JSON/dict immediately upon it's creation -- before the image_json_path (or the json_path) is put to use.

For example, I'm trying to adapt the https://learn.adafruit.com/cleveland-museum-of-art-pyportal-frame project to the Art Institute of Chicago's Public API. The Cleveland project uses image_json_path to locate a .JPG file to display. For the Art Institute of Chicago, the .JPG location can only be found by concatenating the values from two separate key:value pairs and a couple of string constants.

I.e., my json_transform would

json_out["joinedKeys"] = json_out["config"]["iiif_url"] + "/" + json_out["data"][0]["imageID"] + "/full/!320,240/0/default.jpg"

That would leave me free to initialize the PyPortal object with

image_json_path = ["joindKeys"],

I can imagine other use cases for accessing or modifying the JSON/dict data immediately after its creation.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions