3 ms·
”The response should be a JSON object mapping Emoji (as Strings) to their count (as Numbers)” This means ordering semantics are lost.
by helsinki 2y ago
”The response should be a JSON object mapping Emoji (as Strings) to their count (as Numbers)”
This means ordering semantics are lost.
- Retr0id 2y agoWhy would you expect/want ordering semantics here?
- LordDragonfang 2y agoFor many services which allow arbitrary emoji reactions (most notably discord) they remain ordered by "first reacted" order, which can allows emergent behavior like spelling out words with the letter emojis
- Retr0id 2y agoSpelling out words feels like an anti-feature in this context
- dagss 2y agoPurely rationally it may be. But lots of fun being had in our Slack by people putting emojis in the right order, to make pictograms etc All forms of communication is "abused", such abuse is part of being human, that is how languages have evolved..
- grayhatter 2y agoI think misused is connotation you really want. unintentional irreverence versus unintentional maliciousness
- Spivak 2y agoBut JSON mappings are ordered. The thing producing/consuming them might choose to map them to an unordered mapping but inherent to them being serialized is you get an order for free.
- hnlmorg 2y agoThe JSON specification describes objects as unordered. Which means any standards compliant JSON encoders or decoders can and will produce maps in different orders even when the same object is passed through twice. It’s also worth noting that quite a few languages don’t guarantee ordered maps either. If you want an ordered map then you really need a key/value map inside an array: [ { Key: “:thumb:”, Value: 4 }, { Key: “:smile:”, Value: 1 } ] Though in this specific instance, you’d be better off with more specific key names like “emoji” and “count” (respectively). Edit: HN stripped the emojis from my comment so I added ASCII placeholder strings into the example to illustrate the same point.
- 9dev 2y agoNot by the spec. Some implementations may preserve the order, but the JSON spec doesn’t guarantee that, so you cannot rely on it.