Add the data from the JSON file into XMP raw data using JS

Contributor ,
Jan 21, 2022 Jan 21, 2022

Copy link to clipboard

Copied

Hi All,


Is it possible to update the data from json file into Indesign file info XMP rawdata using Indesign JS?

JSON format

JSON data = {
"Name":"XXXX",
"id":"XXXX",
"Address":"XXXX"
}

 

 

 

 

 

 

 

TOPICS
Scripting

Views

78

Likes

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

Adobe Community Professional , Jan 21, 2022 Jan 21, 2022
Hi Rocky@ , Would something like this work? var md = app.activeDocument.metadataPreferences; var ns = "http://ns.adobe.com/xap/1.0/"; var p, v; //the json object var o = {"Name":"John Doe","id":"1234","Address":"Main Street"} var props = o.reflect.properties; for (var i = 0; i < props.length-4; i++){ p = props[i].name v = o[props[i]] md.setProperty(ns, p, v) }; JSON gets added to Raw Data

Likes

Translate

Translate
Adobe Community Professional ,
Jan 21, 2022 Jan 21, 2022

Copy link to clipboard

Copied

LATEST

Hi Rocky@ , Would something like this work?

 

var md = app.activeDocument.metadataPreferences;
var ns = "http://ns.adobe.com/xap/1.0/";
var p, v;

//the json object
var o = {"Name":"John Doe","id":"1234","Address":"Main Street"}
var props = o.reflect.properties;

for (var i = 0; i < props.length-4; i++){
    p = props[i].name
    v = o[props[i]]
    md.setProperty(ns, p, v)
};   

 

JSON gets added to Raw Data

 

Screen Shot 1.png

Likes

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