Skip to content

[Question] Use sjson.Delete in a way to delete not present fields #92

@manuelarte

Description

@manuelarte

Hi,

So Imagine I have the following JSON:

{
 "id": 1,
 "name": "John",
 "surname": "Doe",
 "age": 18,
 "address": {
   "street": "mystreet",
   "city": "mycity",
   "country": "mycountry",
   "zipcode": "1111"
 }
}

With your (amazing) library, it's possible to do, sjson.Delete(json, "name"), but do you know any way to do the "opposite", to let's say delete every field but some of them, something like:

sjson.Keep(json, "name,surname"), resulting in:

{
 "name": "John",
 "surname": "Doe"
}

Thanks

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