rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.61k stars 142 forks source link

Json objects are reordered #228

Closed titouancreach closed 2 months ago

titouancreach commented 1 year ago

In some case, order in json is important and I noticed, keys in json objects are reordered, for example:

###
POST {{Repro_HostAddress}}/du/
Accept: application/json
Content-Type: application/json

{
    "param": {
        "$type": "Circle",
        "radius": 4
    }
}

is

Command: curl -sSL --compressed -X 'POST' -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"param": {"radius": 4, "$type": "Circle"}}' 'http://localhost:5237/du/'

If I change the my request as follow:

{
    "param": {
        "radius": 4,
        "$type": "Circle"
    }
}

The generated request is still:

Command: curl -sSL --compressed -X 'POST' -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"param": {"radius": 4, "$type": "Circle"}}' 'http://localhost:5237/du/'
boltlessengineer commented 2 months ago

Closing this due to v3 release. This is because older versions decode and encode the json body to validate json and inject variables. Now rest.nvim only validates json and inject variables without the context of json syntax.