Skip to content

Latest commit

 

History

History
 
 

JSON-AM-Data-Format

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

JSON AM Data Format

JSON AM descriptor

A descriptor in JSON AM Data Format is represented as a JSON object { } (not to be confused with the Photoshop API Object type, whose tag is "<object>" as described below), where each item in the descriptor is expressed as a unique key unified ID string associated with a “typed value”:

Typed Value Parameters ActionDescriptor Methods
{ "<boolean>": Boolean }
or
[ "<boolean>", Boolean ]
Boolean : true or false desc.getBoolean
desc.putBoolean
{ "<class>": Class }
or
[ "<class>", Class ]
Class : class unified ID string desc.getClass
desc.putClass
{ "<data>": Data }
or
[ "<data>", Data ]
Data : raw byte data string desc.getData
desc.putData
(only from CS2)
{ "<double>": Double }
or
[ "<double>", Double ]
Double : number desc.getDouble
desc.putDouble
{ "<enumerated>": { EnumTypeEnumValue } }
or
[ "<enumerated>", [ EnumTypeEnumValue ] ]
EnumType : enumType unified ID string
EnumValue : enumValue unified ID string
desc.getEnumerationType
desc.getEnumerationValue
desc.putEnumerated
{ "<integer>": Integer }
or
[ "<integer>", Integer ]
Integer : number (signed integer) desc.getInteger
desc.putInteger
{ "<largeInteger>": LargeInteger }
or
[ "<largeInteger>", LargeInteger ]
LargeInteger : number (signed integer) desc.getLargeInteger
desc.putLargeInteger
(only from CS6)
{ "<list>": List }
or
[ "<list>", List ]
List : JSON AM list array desc.getList
desc.putList
{ "<object>": { ClassDescriptor } }
or
[ "<object>", [ ClassDescriptor ] ]
Class : class unified ID string
Descriptor : JSON AM descriptor object
desc.getObjectType
desc.getObjectValue
desc.putObject
{ "<path>": Path }
or
[ "<path>", Path ]
Path : file system path string desc.getPath
desc.putPath
{ "<reference>": Reference }
or
[ "<reference>", Reference ]
Reference : JSON AM reference array desc.getReference
desc.putReference
{ "<string>": String }
or
[ "<string>", String ]
String : string desc.getString
desc.putString
{ "<unitDouble>": { UnitDouble } }
or
[ "<unitDouble>", [ UnitDouble ] ]
Unit : unit unified ID string
Double : number
desc.getUnitDoubleType
desc.getUnitDoubleValue
desc.putUnitDouble

Example

{
    "mode": { "<class>": "RGBColorMode" },
    "width": { "<unitDouble>": { "distanceUnit": 512 } },
    "height": { "<unitDouble>": { "distanceUnit": 512 } },
    "resolution": { "<unitDouble>": { "densityUnit": 72 } },
    "pixelScaleFactor": { "<double>": 1 },
    "fill": { "<enumerated>": { "fill": "white" } },
    "depth": { "<integer>": 8 },
    "profile": { "<string>": "sRGB IEC61966-2.1" }
}

or

{
    "mode": [ "<class>", "RGBColorMode" ],
    "width": [ "<unitDouble>", [ "distanceUnit", 512 ] ],
    "height": [ "<unitDouble>", [ "distanceUnit", 512 ] ],
    "resolution": [ "<unitDouble>", [ "densityUnit", 72 ] ],
    "pixelScaleFactor": [ "<double>", 1 ],
    "fill": [ "<enumerated>", [ "fill", "white" ] ],
    "depth": [ "<integer>", 8 ],
    "profile": [ "<string>", "sRGB IEC61966-2.1" ]
}

JSON AM list

A list in JSON AM Data Format is represented as a JSON array [ ], where each element of the array is a “typed value”:

Typed Value Parameters ActionList Methods
{ "<boolean>": Boolean }
or
[ "<boolean>", Boolean ]
Boolean : true or false list.getBoolean
list.putBoolean
{ "<class>": Class }
or
[ "<class>", Class ]
Class : class unified ID string list.getClass
list.putClass
{ "<data>": Data }
or
[ "<data>", Data ]
Data : raw byte data string list.getData
list.putData
(only from CS2)
{ "<double>": Double }
or
[ "<double>", Double ]
Double : number list.getDouble
list.putDouble
{ "<enumerated>": { EnumTypeEnumValue } }
or
[ "<enumerated>", [ EnumTypeEnumValue ] ]
EnumType : enumType unified ID string
EnumValue : enumValue unified ID string
list.getEnumerationType
list.getEnumerationValue
list.putEnumerated
{ "<integer>": Integer }
or
[ "<integer>", Integer ]
Integer : number (signed integer) list.getInteger
list.putInteger
{ "<largeInteger>": LargeInteger }
or
[ "<largeInteger>", LargeInteger ]
LargeInteger : number (signed integer) list.getLargeInteger
list.putLargeInteger
(only from CS6)
{ "<list>": List }
or
[ "<list>", List ]
List : JSON AM list array list.getList
list.putList
{ "<object>": { ClassDescriptor } }
or
[ "<object>", [ ClassDescriptor ] ]
Class : class unified ID string
Descriptor : JSON AM descriptor object
list.getObjectType
list.getObjectValue
list.putObject
{ "<path>": Path }
or
[ "<path>", Path ]
Path : file system path string list.getPath
list.putPath
{ "<reference>": Reference }
or
[ "<reference>", Reference ]
Reference : JSON AM reference array list.getReference
list.putReference
{ "<string>": String }
or
[ "<string>", String ]
String : string list.getString
list.putString
{ "<unitDouble>": { UnitDouble } }
or
[ "<unitDouble>", [ UnitDouble ] ]
Unit : unit unified ID string
Double : number
list.getUnitDoubleType
list.getUnitDoubleValue
list.putUnitDouble

Example

[
    { "<string>": "Times" },
    { "<string>": "Helvetica" },
    { "<string>": "Monaco" }
]

or

[
    [ "<string>", "Times" ],
    [ "<string>", "Helvetica" ],
    [ "<string>", "Monaco" ]
]

JSON AM reference

A reference in JSON AM Data Format is represented as a JSON array [ ], where each element of the array is either:
DesiredClassTypedValue }
or
DesiredClassTypedValue ]

DesiredClass is a class unified ID string, and TypedValue is a “typed value”:

Typed Value Parameters ActionReference Methods
{ "<class>": null }
or
[ "<class>", null ]
(none) (none)
ref.putClass
{ "<enumerated>": { EnumTypeEnumValue } }
or
[ "<enumerated>", [ EnumTypeEnumValue ] ]
EnumType : enumType unified ID string
EnumValue : enumValue unified ID string
ref.getEnumeratedType
ref.getEnumeratedValue
ref.putEnumerated
{ "<identifier>": Identifier }
or
[ "<identifier>", Identifier ]
Identifier : number (unsigned integer) ref.getIdentifier
ref.putIdentifier
{ "<index>": Index }
or
[ "<index>", Index ]
Index : number (unsigned integer) ref.getIndex
ref.putIndex
{ "<name>": Name }
or
[ "<name>", Name ]
Name : string ref.getName
ref.putName
{ "<offset>": Offset }
or
[ "<offset>", Offset ]
Offset : number (signed integer) ref.getOffset
ref.putOffset
{ "<property>": Property }
or
[ "<property>", Property ]
Property : property (key) unified ID string ref.getProperty
ref.putProperty

Example

[
    { "property": { "<property>": "histogram" } },
    { "channel": { "<enumerated>": { "channel": "green" } } },
    { "layer": { "<name>": "Hulk" } },
    { "document": { "<index>": 1 } }
]

or

[
    [ "property", [ "<property>", "histogram" ] ],
    [ "channel", [ "<enumerated>", [ "channel", "green" ] ] ],
    [ "layer", [ "<name>", "Hulk" ] ],
    [ "document", [ "<index>", 1 ] ]
]

Unified ID string

ID String Unified Syntax Examples Application Methods
CharID Four-letter “mnemonic” string
surrounded by single quotation marks:
"'xxxx'"
"'Rd  '"
"'Grn '"
"'Bl  '"
"'H   '"
"'Axis'"
"'#Pxl'"
app.charIDToTypeID
app.typeIDToCharID
StringID Plain “human-readable” text string:
"xxxxxxxx"
"red"
"green"
"blue"
"hue"
"axis"
"pixelsUnit"
app.stringIDToTypeID
app.typeIDToStringID

Note: In Photoshop, all internal IDs are strictly positive integers; they are normally represented by more “readable” strings known as CharIDs and StringIDs, converted to numerical IDs by app.charIDToTypeID and app.stringIDToTypeID respectively. Any CharID or StringID can actually be used as long as they are equivalent, i.e., they get converted to the same numerical ID.

Notes

  • A JSON object is an unordered collection of name/value pairs. It begins with { (left brace) and ends with } (right brace). Each name is a string followed by : (colon) and the name/value pairs are separated by , (comma).

  • A JSON array is an ordered sequence of values. It begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).

  • A value can only be: a string, a number, an object, an array, or true, false and null.

  • All strings must be enclosed in double quotes.

  • As an extra reminder, it should be noted that the following JavaScript statements:

var myObject = { };
var myArray = [ ];

are strictly equivalent to:

var myObject = new Object ();
var myArray = new Array ();