'Javascript decoding unicode returns `undefined`

I have this two different unicodes in my .Json file:

\u30a2\u30eb\u30d0
\u0410\u043d\u0433\u0438\u043b\u044c\u044f 

Javascript code uses const data = require('./countries.json'); to access this .Json file and extract this values. But, it can only decode second one, for the first one it returns undefined error. Can anyone explain me why?



Solution 1:[1]

I don't know how you access those values, but I've recreated your scenario and it does work like expected.

Here my values.json

{
  "official": "\u30a2\u30eb\u30d0",
  "common": "\u0410\u043d\u0433\u0438\u043b\u044c\u044f"
}

Here my Node code

const values = require("./values.json");
console.log(values.common);
console.log(values.official);

Expected output:

???????
???

I can only guess that you are trying to access a value with a key that does not exist or you are missing quotes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mushroomator