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

How to parse Javascript Object Notation in Extendscript?

New Here ,
May 12, 2010 May 12, 2010

I noticed in Dr. Brown's Image Processor the following code:

dialogResource =  "dialog { text: 'Image Processor', bounds:[100, 100, 480, 540], "

which is basically assigning object notation to the dialogResource variable.  Then later in the script you see:

mainDialog = new Window( this.dialogResource );

Which means Window() takes the object notation and creates a window object using it.  This also means the object notation is being parsed.

There's another post that allows you to use the Socket() to pull data right off a website (like a web service), so I am really interested in downloading JSON and turning it into local objects.

Any ideas on how to turn JSON into valid objects in ExtendScript?

TOPICS
Actions and scripting
4.4K
Translate
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

Mentor , May 12, 2010 May 12, 2010

Extendscript is just Adobe's flavor of javascript so you could just eval the json string. Or you could use one of the json parsers like http://www.json.org/json2.js

Translate
Adobe
Mentor ,
May 12, 2010 May 12, 2010

Extendscript is just Adobe's flavor of javascript so you could just eval the json string. Or you could use one of the json parsers like http://www.json.org/json2.js

Translate
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 ,
Apr 27, 2012 Apr 27, 2012
LATEST

I've been using this parser (for generating JSON, not parsing), but Photoshop is incredibly unstable when running my scripts and I suspect json2.js is the culprit. Does anyone have experiencing with json2.js in Photoshop?

Translate
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
Advisor ,
May 12, 2010 May 12, 2010

One note: ScriptUI resource strings are not quite json strings.

Translate
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