How do I set a variable to the contents of a ".json" file?

2970
2
04-11-2016 02:10 PM
JoshuaMcCurry
New Contributor III

Very new to coding...I am trying to set a variable to the contents of an external ".json" file. It contains an array. I can't figure out how to reference the file correctly in html/javascript and set the variable simply to the array. Thanks for any advise.

Tags (3)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Joshua,

  Sure just use 'dojo/text!pathyourjsonfile.json' in your apps require statements and then use the assigned parameter (i.e. myJson) to access it in your code.

JeffJacobson
Occasional Contributor III