I have an html5
banner created with flash cc
. The platform I am using to display/run the ad does not accept JSON
files.
How do I take the info from the JSON
and put it either into my .html
or .js
file so I can eliminate the JSON
all together.
Asked
Active
Viewed 337 times
-1

william.eyidi
- 2,315
- 4
- 27
- 39
-
Try this: `var yourJSON='json'` – Rayon Oct 26 '15 at 15:38
-
1JSON is a subset of JavaScript, so you... just put it in the file. – ssube Oct 26 '15 at 15:40
-
This question is a bit broad to fit properly on stackoverflow. Is the json file static or created dynamically? Whave have you tried? Also, keep in mind that json stands for JavaScript Object Notation and hence can be parsed easily into an object/array. I also think this may be a duplicate: http://stackoverflow.com/questions/4935632/parse-json-in-javascript – k0pernikus Oct 26 '15 at 16:43
-
think of validating the correct answer @Dawn – william.eyidi Oct 28 '15 at 15:21
2 Answers
0
Assign the JSON data to a normal javascript variable inside of a <script>
element in your HTML file.

Jason
- 31,834
- 7
- 59
- 78
0
You have these two approaches:
HMTL
<script type='text/javascript'>
var jsonContent = JSON.parse("{name: 'json content in html'}");
</script>
javascript
var jsonContent = JSON.parse("{name: 'json content in javascript file'}");

william.eyidi
- 2,315
- 4
- 27
- 39
-
1OR, the most sensible one: `var jsonContent = {name: 'json content in javascript file'};` – Lee Taylor Oct 26 '15 at 20:10
-
the point of having it in a variable is to be able to manipulate it, it will make sense to keep `JSON.parse()` @LeeTaylor – william.eyidi Oct 26 '15 at 20:12
-
Who said it was a variable? Once it's inside jsonContent it is variable anyway... – Lee Taylor Oct 26 '15 at 21:33
-
Yes but a variable with type string while parsing it results in an object. That makes it easier to manipulate – william.eyidi Oct 26 '15 at 22:06