Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #20661

    I’m trying to implement a JSON-beautifier in an EmEditor macro, but when I attempt to use for example the JSON.parse() method (which is part of the Javascript specification), I only get the following error message:
    ‘JSON’ is undefined
    Does Javascript macros in EmEditor only support a subset of Javascript standard, and in that case which parts?

    Here is a link to the part of the Javascript reference that documents the build-in JSON object:


    Hi LifeTimer,

    EmEditor utilize the ‘Windows Script Host’, which in turn utilize JScript 5.7 feature set.
    Even as WSH says it’s 5.8

    jsV = ScriptEngineMajorVersion() +"."+ ScriptEngineMinorVersion();
    alert(jsV); // 5.8



    Note Starting with JScript 5.8, by default,
    the JScript scripting engine supports the language feature set as it existed in version 5.7.
    This is to maintain compatibility with the earlier versions of the engine.

    From MSDN:

    JScript 5.8 introduced the following features: JSON object, JSON.parse method,
    JSON.stringify method, toJSON method, defineProperty method, getOwnPropertyDescriptor method.

    And further see:
    and perhaps:



    On the MSDN page listed above is this:

    To use the complete language feature set of version 5.8, the Windows Script interface host has to invoke IActiveScriptProperty::SetProperty.

    Is this something on the drawing board? Or is it a setting already in EmEditor and I missed it?

    Yutaka Emura


    On the next beta version (v15.9.0 beat 3), I added the versioning code to set JScript version to 5.8, but unfortunately, it doesn’t seem working. I will still look into the issue.


    Sorry, I missed this reply before (missing forum email notifications again…).

    Did you ever get it working in the 15.9.0 final version?

    If not, there really must be a way to get it working, since it’s such widespread functionality, used by thousands of applications around the world, right?!

    I could absolutely help you to search for clues towards a solution if you just describe the problem a bit further here (i.e. if you didn’t already got it working in the 15.9.0 final version?).

    The following info might be of value:

    Perhaps especially the following quote?

    The undocumented ‘feature’ of the SetProperty with SCRIPTPTOP_INVOKEVERSIONING is that the value must be a VT_I4 or VT_I2 – any other integer type will be rejected as invalid.

    Yutaka Emura

    EmEditor v15.9.0 supports the JSON object. Here is an example:

    var text = '{ "employees" : [' +
     '{ "firstName":"John" , "lastName":"Doe" },' +
     '{ "firstName":"Anna" , "lastName":"Smith" },' +
     '{ "firstName":"Peter" , "lastName":"Jones" } ]}';
    var obj = JSON.parse(text);
    alert( obj.employees[1].firstName + " " + obj.employees[1].lastName );

    I hope this helps. Thanks for your inputs!


    Thanks a lot for adding this, it works great!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.