Skip to content

Order of JSON key, value pairs  #148

@kimmobrunfeldt

Description

@kimmobrunfeldt

I'm not sure if this is a flaw in JWT specification or if I don't understand something. In JWT, the order of JSON key, value pairs matters when encoding and decoding tokens. Having {"alg": "HS256", "typ": "JWT"} headers produces different token compared to {"typ": "JWT", "alg": "HS256"}.

This seems weird to me because JSON specification states that the key, value pairs do not have an order: An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma). source.

jwt

Do you have an explanation for this?

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