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

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

Contributor ,
Jan 21, 2022 Jan 21, 2022

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
516
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

Community Expert , 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

 

Screen Shot 1.png

Translate
Community Expert ,
Jan 21, 2022 Jan 21, 2022
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

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