INNER CODE UNIT · Python

update_json_field

jpush/jpush-react-native · .claude/skills/update-sdk/scripts/plugin_updater.py:93

def update_json_field(file_path: str, key: str, new_version: str) -> bool:
    """Update a field in a JSON file (supports dot-notation keys)."""
    path = Path(file_path)
    if not path.exists():
        print(f"  WARNING: File not found: {file_path}")
        return False

    with open(path, "r", encoding="utf-8") as f:
        data = json.load(f)

    keys = key.split(".")
    obj = data
    for k in keys[:-1]:
        obj = obj.setdefault(k, {})

    old = obj.get(keys[-1], "unknown")
    if old == new_version:
        print(f"  SKIP: {file_path} [{key}] already at {new_version}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…