Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

New To APIs

What is the difference between ".js" and ".json" scripts
1472823519

Edited 1472823549
To install an API Script; copy, paste and save the contents of a .js file into a New Script tab of the Script Editor. For more information, please see:&nbsp; <a href="https://wiki.roll20.net/API:Introduction" rel="nofollow">https://wiki.roll20.net/API:Introduction</a> I hope this helps!
1472823554
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
.js are JavaScript code files. .json are json formatted files. In the roll20 repository script.json files are where the info that is displayed when you select it in one-click is stored. The js files are what contain the code.
You guys Rock. &nbsp;Thanks so much. &nbsp;I have only been on Roll20 a month but I am an addict for sure and people like you guys in the community make it so easy to learn and figure things out!
1472825559
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'd recommend checking the on click drop down for the script you are looking for before going the copy paste route. The one click install will also pull any dependencies the script may have and avoids the potential problem of copy paste induced script errors.
Thanks Scott. &nbsp;I have been sticking to them mostly
1472871016
Lithl
Pro
Sheet Author
API Scripter
JS: JavaScript JSON: JavaScript Object Notation
Thank You Brian &nbsp;What is JavaScript Object Notation for? &nbsp;I mean that isn't what i plug into the API right?
1472895069
Lithl
Pro
Sheet Author
API Scripter
JSON is simply a particular format for storing information, similar to XML or CSV. In the case of the API repository, the file script.json stores information about &nbsp;the script, and that information is used for the One-Click Installation feature. If you're copying the script manually, you can safely ignore it (the "description" field might contain useful information for you, though). When it comes to API code itself, some data for game objects is stored as JSON. For example, the turn order is accessed with Campaign().get('turnorder') , but the result is a (JSON) string. In order to get a useful structure, it has to be parsed. Fortunately, there is a built-in function to do that, so a script author trying to get the current turn order would use JSON.parse(Campaign().get('turnorder')) . In order to change the turn order, you'd have to do the reverse: Campaign().set('turnorder', JSON.stringify( myNewTurnOrder)) .
Thanks Brian.