• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

faster JSON parsing: json2.js vs json3.js

Community Beginner ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

So I've been looking for a faster way to parse large JSON files in Illustrator scripting and I think I may have found a solution if anyone else is ever looking for this:
Instead of the standard json2.js (https://github.com/douglascrockford/JSON-js) I came across json3.js (https://github.com/bestiejs/json3) as a drop-in replacement.

In my use case (5mb+ JSON files), JSON.parse() is ~60x faster (5 seconds vs 5 mins)  - seems to just be a more modern and faster implementation. 

Only issue I've seen so far is a bit of funkiness with how it handles escaped non-Ascii characters.
Anybody else have experience with these libraries or know of any issues that might come up switching from json2 to json3?

TOPICS
Performance , Scripting , SDK

Views

401

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Mar 24, 2023 Mar 24, 2023

update for the "escaped non-Ascii characters" issue mentioned above:
line 642 in json3.js needs extra () to evaluate properly in Illustrator script for some reason or it will error on certain escaped characters (/u00ed for instance). I made a fork of json3 with this change if anyone needs it: https://github.com/sam272/json3forillustrator/blob/c98707a15a3d88f393749c6678ffbc43f89f4d53/lib/json3.js#L642

Will update with any other issues I find.

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

HI @sam272, I've been using json3.js since forever, because if I recall correctly, it handled recursive references better. I honestly didn't know it was faster. I can say that it has performed well for me. - Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 24, 2023 Mar 24, 2023

Copy link to clipboard

Copied

update for the "escaped non-Ascii characters" issue mentioned above:
line 642 in json3.js needs extra () to evaluate properly in Illustrator script for some reason or it will error on certain escaped characters (/u00ed for instance). I made a fork of json3 with this change if anyone needs it: https://github.com/sam272/json3forillustrator/blob/c98707a15a3d88f393749c6678ffbc43f89f4d53/lib/json...

Will update with any other issues I find.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2023 Jul 28, 2023

Copy link to clipboard

Copied

LATEST

Hi @sam272, I only just saw this now. Good spotting!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines