Skip to content

indent param #25

Closed
Closed

Description

@kenrobbins

if a string is passed to indent, the indent char is the first char of the string and the indent char count is the length of the indent string. e.g. indent="\t\t" would be 2 tabs (but so would indent="\tA".

decide whether to keep this. might be nice if someone wanted to use tabs instead of spaces.

if kept, need to raise an exception if the string is not ascii.

Activity

  1. sontek commented on Sep 17, 2015

    @sontek
    Contributor

    I think staying compatible with the python stdlib would be nice here, so only supporting integers indent=4. The stdlib uses the separators kwargs to allow people to add tabs if they want

  2. kenrobbins commented on Sep 17, 2015

    @kenrobbins
    MemberAuthor

    The stdlib supports strings now:

    If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0, negative, or "" will only insert newlines. None (the default) selects the most compact representation. Using a positive integer indent indents that many spaces per level. If indent is a string (such as "\t"), that string is used to indent each level.

    Changed in version 3.2: Allow strings for indent in addition to integers.

    https://docs.python.org/3/library/json.html

    It will be easier and less weird if we only support ints though.

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

Metadata

Metadata

Assignees

No one assigned

    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