I have a json file that contain at some places a “eval” property that contain javascript code. My goal is to be able to have it display like it’s was a javascript file.
This is an example file :
{
"fn": "zcl:attr",
"ep": 1,
"cl": "0x0000",
"at": "0x000A",
"eval": "Item.val = Attr.val"
}
Here the code Item.val = Attr.val
is javascript
I tried some suggestion made by copilot but did not get a good result;
monaco.languages.setMonarchTokensProvider('json', {
tokenizer: {
root: [
[/"eval"s*:s*"(.*)"/, {
token: 'source.js',
nextEmbedded: 'javascript',
log: 'eval detected',
}],
[/"[^"]*"/, 'string'],
[/bd+b/, 'number'],
[/[{}[],]/, 'delimiter'],
[/:/, 'delimiter.colon'],
[/s+/, 'white'],
],
},
})
I also did some researchs on existing code but found nothing that I was able to make it work