Skip to content

Allow omitting empty keys #59

@radeksimko

Description

@radeksimko

The default golang JSON (un)marshal implementation respects omitempty inside a field's tag which will effectively omit such field from the resulting JSON if it's not defined in a given struct.

Field int `json:"myName,omitempty"`

I was wondering if there's any interest in such feature for this library - i.e. support something like this:

type Profile struct {
    First  string `ini:"first"`
    Second string `ini:"second,omitempty"`
}

The current implementation doesn't interpret commas in any special way which results in the following output:

[my-section]
first            = custom-value
second,omitempty = 

The expected behaviour would be

[my-section]
first = custom-value

Is there any reason to support commas inside key names? 😺

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions