This question is possibly duplicated, but I look for a different approach. The situation is this: I made a small program to create a JSON file, creating names and assigning values. The target of the JSON when read will be an object, so the names have property identifiers. It would be interesting to filter the field names more strictly, obeying the language criteria.
Edited: Bruno Vianna warns of the fact that JSON is different from literal object, even though the structure is the same. Doing a JSON correctly does not solve the problem since it has different rules (see example).
What I got from information are instructions on how to create a name that does not give a problem when developing the code. There is a MDN page and also a similar question from here with an exhaustive answer. To start the identifier is easy: a letter, _ or $. The rest I did not find a character set or regular expression to fetch problems, and there are still reserved names. All this has to be listed for a verifier. My alternative so far is to follow the pattern of Unix file names, remove spaces, etc. which is quite conservative.
Has anyone done a tester yet? Do you know any?
EDITED: Example: this JSON has been validated by JSONLint
var str = '{"prop+1": "valor1","%prop2": "valor2"}';
var obj = JSON.parse(str);
var res = '<h1>Teste</h1>';
res += '<li>' + obj["prop+1"] + '</li>';
res += '<li>' + obj["%prop2"] + '</li>';
res += '<li>' + obj.prop+1 + '</li>';
res += '<li>' + obj.%prop2 + '</li>';
document.getElementById("result").innerHTML = res;
The code did not work in jsfiddle - I even thought the properties would be accessible in quotes, but not. Anyway, they are problematic identifiers that happen at first (creation of JSON) but they can give problem later.