These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Any Idea on how to use JSON in a form?

Jimmy0306
Registered: Dec 11 2008
Posts: 32
Answered

I have a form that I would like to use a specific value from a JSON response (URL). I can make all the data show up in my textfield, but I'd like to only show one value of a specific name/value pair. Thanks in advance for the help!

My Product Information:
LiveCycle Designer, Windows
Jimmy0306
Registered: Dec 11 2008
Posts: 32
OK..So I figured out the answer to my own question! Since JSON in a subset of Java, then why not use a simple eval on the text string in create a Java Object? (This may be elementary to some, but here is how I made my form interact with JSON.)

1. I created two fields (Lat and Long).
2. I have a simple REST HTTP that is something like "http://sampleserver...=json"
3. I use the Concat (FormCalc) to create a new text string with the User Supplied Lats and Longs.
4. I use Get(Formcalc) to return the JSON string into a TextField
5. Finally, I used Javascript to extract the data of interest:

var myJSON = TextField.rawValue
var val = eval("(" + myJSON + ")");
val.results[0].attributes.value

(The last line depends on the structure of the JSON response)

I love when answers are simple and easy to find. That's why I answered my own question.