Issue
Ok, a question regarding JSON and UTF-8/unicode encoding. My simple stack is to be Backend: MongoDB + GraphQL, FrontEnd: Flutter app.
There’s no doubt there’s an international coding standard of naming things in English for a data model like {"firstName":"Oscar"} when storing data and later parsing data in apps, and that’s fine.
However, if the code for my project is only intended to be reviewed by and additional work done by other native speaking coders (Swedish in this case), are there any bad reasons to name the data model fields as {"fornamn":"Oscar"} or even using the Unicode-key {"förnamn":"Oscar"} when it comes to either storing, fetching or parsing JSON to both the MongoDB document, GraphQL resolvers and then the Flutter dart class model?
Why would I like to store it localized? - Because some of the fields and data structures make more sense and are easier to conceptualize when mentally modelled in the native tongue as opposed to translating to English back and forth.
Solution
Using JSON with Unicode characters is perfectly fine. This also applies to keys in JSON objects. I don't see any reason why not.
JSON should always be saved/transferred using a Unicode encoding, preferably UTF-8. If a non-Unicode encoding is used, the JSON needs to be rewritten using escape sequences for characters not available in that encoding. This applies equally to keys and other JSON elements.
Answered By - Codo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.