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

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

311

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

Votes

Translate

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

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