Skip to content

Question: Insert a new property key at a certain position #17

@cweiske

Description

@cweiske

I'm trying to add a new object property at a certain position and not at the end.

I know the property position inside an object is not relevant in JSON, but I want to have my keys sorted alphabetically:

{
  "package": com.DefiantDev.SkiSafari",
  "images": {
    "companion-app": "http://gamestick.cweiske.de/archive/gamestick_com.DefiantDev.SkiSafari/companion-app.png"
    "logo-1": "http://gamestick.cweiske.de/archive/gamestick_com.DefiantDev.SkiSafari/logo-1.png",
    "logo-2": "http://gamestick.cweiske.de/archive/gamestick_com.DefiantDev.SkiSafari/logo-2.png",
  }
}

The companion-app is new, and I'd like to have it added at the beginning of the images object.

What can I do to add a new JSON property at the beginning of an object?

What I tried

This patch adds it at the end of the property list:

{
    "images": {
        "companion-app {render}": "http://gamestick.cweiske.de/archive/gamestick_{{ _get('.package') }}/companion-app.png"
    }
}

Assigning positions is not allowed because it isn't a list:

{
    "images {extend@1}": {
        "companion-app {render}": "http://gamestick.cweiske.de/archive/gamestick_{{ _get('.package') }}/companion-app.png"
    }
}

ERROR .images {extend@1}: Cannot execute operation "extend" with value dictionary with keys [companion-app {render}]. This operation requires a value of type list

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