About
Objective
Purpose
Concepts
Philosophy
ILA
GCI
What Next?
Matrix
Terms
Privacy
Aspects
Facets
Research
Programming
Design
Professions
Scientist
Developer
Artist
Achievements
Ranks
Grades
Titles
Content
Data/Entries/Relations
Blog/Posts/Comments
Wiki/Pages/Tags
Articles (Reports/Reviews)
Ontology
Tutorials
Links
Media
Polls
Questionnaires
Repository
Annotations
Classifications
Tissues
Species
Interactions
Expressions
Profiles
Signatures
Intersections
Sets
Meta
Datasets
Create
References
Archive
Changes
Lifespan
Studies
Experiments
Measurements
Comparisons
Interventions
Factors
Variants
Assays
Strains
Regimens
Manipulations
Epistases
Experts
Profiles
Collaborations
Com
Messaging
Announcements
Video
Donate
Log in
or
Sign up
Denigma
>
Wiki
> Page = JSON > Edit
o
Start
|
Search
|
Index
Mouse Lifespan Experiments
(
Hide
)
Wiki
JSON - Editing
leave this field blank to prove your humanity
// This is an example of how the JSON would be structured. // Note that chaingun_impact.png is not here. // // Note that this is an actual Javascript object, whereas // JSON is a string that represents that object. JSONExample = { "frames": { "chaingun.png": { "frame": { "x": 1766, "y": 202, "w": 42, "h": 34 }, "rotated": false, "trimmed": true, "spriteSourceSize": { "x": 38, "y": 32, "w": 42, "h": 34 }, "sourceSize": { "w": 128, "h": 128 } }, "chaingun_impact.png": { "frame": { "x":1162, "y":322, "w":38, "h":34}, "rotated": false, "trimmed": true, "spriteSourceSize": { "x":110, "y":111, "w":38, "h":34}, "sourceSize": { "w":256, "h":256} }, "chaingun_impact_0000.png": { "frame": { "x": 494, "y": 260, "w": 22, "h": 22 }, "rotated": false, "trimmed": true, "spriteSourceSize": { "x": 113, "y": 108, "w": 22, "h": 22 }, "sourceSize": { "w": 256, "h": 256 } } } }; // The above is an example of how the JSON would be structured. // Note that chaingun_impact.png is not here, we'll call your // parseJSON function with the full JSON input. // // Note also that the above is an actual Javascript object, whereas // JSON is a string that represents that object. parseJSON = function (weaponJSON) { // First, use the JSON.parse function to // parse the passed in weaponJSON. weapon = JSON.parse(weaponJSON); //print(weapon); // Next, grab the 'x' data field within // 'spriteSourceSize' of 'chaingun_impact.png' x = weapon['frames']['chaingun_impact.png']['spriteSourceSize']['x']; // After that, print this value to the console // and also return it. // YOUR CODE HERE var weapon = JSON.parse(weaponJSON); var x = weapon['frames']['chaingun_impact.png']['spriteSourceSize']['x'] console.log(x); return x; };
Tags: