Skip to content

toJSON vs stream_out differences #460

Description

@r2evans

toJSON() and stream_out() behave differently when digits= is not set.

jsonlite::toJSON(tb, verbose = FALSE)
# [{"x":3.1416}] 
jsonlite::stream_out(tb, verbose = FALSE)
# {"x":3.14159}   # <--- not 4 digits
jsonlite::toJSON(tb, verbose = FALSE, digits = 4)
# [{"x":3.1416}] 
jsonlite::stream_out(tb, verbose = FALSE, digits = 4)
# {"x":3.1416}
jsonlite::toJSON(tb, verbose = FALSE, digits = 9)
# [{"x":3.141592654}] 
jsonlite::stream_out(tb, verbose = FALSE, digits = 9)
# {"x":3.141592654}

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