<@ULVA73B9P> I use from prefect.blocks.system impo...
# ask-marvin
f
@Marvin I use from prefect.blocks.system import JSON in Prefect 2, how can I use this in Prefect 3?
m
thought for 133.6 seconds
Short answer: In Prefect 3,
prefect.blocks.system.JSON
was removed. Use Variables for non-sensitive JSON config, and use the Secret block for sensitive JSON. - Variables (recommended for non-sensitive JSON) - Store
Copy code
from prefect.variables import Variable

    Variable.set("app_config", {"api_url": "https://...", "retries": 3}, overwrite=True)
- Load
Copy code
from prefect.variables import Variable

    config = Variable.get("app_config")  # returns the dict directly
- Docs: Variables conceptVariables API - Secret block (use for sensitive JSON, e.g., credentials) - Store
Copy code
from prefect.blocks.system import Secret

    Secret(value={"api_key": "sk-...", "region": "us-west-2"}).save("api_credentials", overwrite=True)
- Load
Copy code
from prefect.blocks.system import Secret

    creds = Secret.load("api_credentials").get()  # returns a dict
- Docs: Secret block APIBlocks concept Quick migration example - Prefect 2 (before)
Copy code
from prefect.blocks.system import JSON

  cfg = JSON.load("app_config").value
- Prefect 3 (after, non-sensitive)
Copy code
from prefect.variables import Variable

  cfg = Variable.get("app_config")
Notes - Variables are not encrypted and have a size limit (~5,000 chars). Use Secret for sensitive JSON, or consider a custom Block if you need structure/methods.