Skip to content

Empty JSON output is 'null' instead of '[]' — breaks jq pipelines #16

Closed

Description

@DTTerastar

Severity

major

Summary

Every export subcommand emits the literal string null (plus newline) on stdout when there is no data in the window. The contract (and the CLI's own prime text) say empty results must be [] so callers can pipe to jq without special-casing.

Reproduce

$ withings-export activity --since 2030-01-01 --json
null
$ withings-export sleep --since 2030-01-01 --json
null
$ withings-export workouts --since 2030-01-01 --json
null
$ withings-export measurements --since 2030-01-01 --json
null
$ withings-export measurements --types 999 --since 30d --json
null

jq 'length' <<< null errors: jq: error: null (null) has no length.

Expected

Empty results print []\n, exit 0. Already fixed on main in commit b580683 (printJSON reflects on nil slices), but missing from the v0.2.1 release. See #14.

Activity

  1. DTTerastar commented on Apr 25, 2026

    @DTTerastar
    ContributorAuthor

    Does not reproduce against HEAD b580683. Verified across all five export subcommands: activity|sleep|workouts|measurements|intraday --since 2030-01-01 --format json each emit [] with EXIT=0. Also measurements --types 999 --since 30d --format json -> []. Fixed in commit b580683. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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