Skip to content

json output failed for empty file #44

@niyue

Description

@niyue

It will be great if the empty file case can be handled when outputting json.

steps to reproduce this issue

❯ touch /tmp/test.txt # create an empty file

❯ pcstat /tmp/test.txt
+---------------+----------------+------------+-----------+---------+
| Name          | Size (bytes)   | Pages      | Cached    | Percent |
|---------------+----------------+------------+-----------+---------|
| /tmp/test.txt | 0              | 0          | 0         |     NaN |
+---------------+----------------+------------+-----------+---------+

❯ pcstat -json /tmp/test.txt
2025/04/21 13:50:33 JSON formatting failed: json: unsupported value: NaN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions