JavaScript Tutorial
  • 🍼Introduction
  • 🥛Hello Gamers
  • 🍯Variables
    • Action Game Example
  • 🌰Strings
    • RPG Example
  • 🍪Character Acces
    • Simulation Example
  • 🍩Plus (+) operator
    • Strategy Game Example
  • 🥜Functions
    • Adventure Game Example
  • 🍿Template strings
    • Strategy Game Example
  • 🍫Numbers
    • Sports Game Example
  • 🍬Converting Numbers to Strings
    • Fighting Game Example
  • 🍭Operations
    • FPS Game Example
  • 🍮Conditions
    • Platformer Game Example
  • 🎂Arrays
    • Puzzle Game Example
  • 🍰Objects
    • Racing Game Example
  • 🧁Arrow Functions
    • Rhythm Game Example
  • 🔌Shameless Plug
  • 🥧Implicit Return
    • Platform Game Example
  • 🍦String Methods
    • GRID Game Example
  • 🍨Object Literals
    • Board Game Example
  • 🍧DynamicProperty
    • Political Game Example
  • 🍡Reading Dynamic Property
    • Hide & Seek Game
  • 🥮Objects Continued
    • Medieval Game Example
  • 🥠Object Shorthands
    • Trivia Game example
  • 🔌Shameless Plug (again)
  • 🍥Destructuring & Concatenation
    • Dig a hole game example
  • 🍏Optional Chaining
    • Action Game Example
  • 🍐Nullish coalescing operator
    • Adventure Game Example
  • 🍊Refactoring If Conditions
    • Arcade Game Example
  • 🍋Implicit Conversion & Falcy Values
    • Strategy Game Example
  • 🍌Arrays of objects
    • Sports Game Example
  • 🍉Transforming Array of Objects
    • Fighters Game Example
  • 🍇Some important array methods
    • FPS Example
  • 🫐Reducing arrays of objects
    • Third Person Shooter Example
  • 🍓Try....catch
    • Platformer Example
  • 🍈Immutability
    • Puzzle game example
  • 🍒Creating new arrays or objects
    • Racing Game Example
  • 🔌Shameless Plug (again)
  • 🍑Immutable object operations
    • Basics
    • Rhythm Game Example
  • 🥭Classes
    • Basics
    • Platformer Game Example
  • 🍍Instance Method
    • Basics
    • Role-playing game example
  • 🥥Object Oriented Programming
    • Basics
    • Stealth Game Example
  • 🥝Getters & Setters
    • Basics
    • Survival Game Example
  • 🍅Static Methods & Chaining
    • Basics
    • Tactical Role Playing Game
  • 🍆Class Inheritance
    • Tower Defense Game Example
  • 🥑Use of Super
    • Vehicular Combat Game example
  • 🫒Public Class Field
    • MMORPG Example
  • 🥦Private class fields
    • Battle Royale Games Example
  • 🥬Aysnc/Await
    • Collectible Card Game example
    • Video Board game example
  • 🫑SetTimeout
    • Dice game example
  • 🥒Execution Order
    • Digital Collectible Card Game example
  • 🌶️The callback pattern
    • Life Simulation Game example
  • 🌽Promises
    • Music Game Example
  • 🥕Writing a function that returns a promise
    • Party game example
  • 🧄Introduction to JSON
    • Tile based game example
  • 🧅JSON.parse(string) / JSON.stringify(object)
    • Rhythm action game example
  • 🍠JSON Example for a game
    • Fetching JSON game data
  • 🥐Handling fetch errors
    • Fetch and HTTP Requests
  • 🥯ES Modules
    • Tower Defence Game Example
  • 🍞Default Export
    • Strategy Adventure Game Example
  • 🥖Fetch Wrapper
    • Strategy Role-playing game example
  • 🔌Final Shameless Plug
  • 🫓Lexical Scope and Arrow Functions
    • Vehicular Combat Game Example
  • 🥨Passing Functions
    • Vehicular simulation game example
  • 🥚Dynamic Imports
    • Video card game example
  • 🍠What is a closure
    • Video casino game example
  • 🎆Congratulations
Powered by GitBook
On this page

JSON Example for a game

PreviousRhythm action game exampleNextFetching JSON game data

Last updated 2 years ago

How would a JSON data for a computer game look like? You can see the data live at or below

{
  "player": {
    "name": "Jane Doe",
    "class": "Warrior",
    "level": 15,
    "hp": 150,
    "strength": 20,
    "dexterity": 15,
    "intelligence": 10,
    "inventory": ["sword", "shield", "healing potion"],
    "questLog": [
      { "name": "Rescue the Princess", "status": "in progress" },
      { "name": "Defeat the Dragon", "status": "not started" }
    ]
  },
  "npcs": [
    {
      "name": "Bob",
      "location": "town square",
      "dialogue": "Hello adventurer! Are you here to help with the goblin problem?"
    },
    {
      "name": "Alice",
      "location": "inn",
      "dialogue": "Welcome to the inn. Would you like a room for the night?"
    }
  ],
  "enemies": [
    { "name": "Goblin", "hp": 10, "attack": 3, "defense": 1 },
    { "name": "Skeleton", "hp": 20, "attack": 5, "defense": 2 }
  ],
  "items": [
    { "name": "healing potion", "description": "Restores 50 HP.", "value": 50 },
    {
      "name": "strength potion",
      "description": "Temporarily increases strength by 5.",
      "value": 75
    }
  ],
  "quests": [
    {
      "name": "Rescue the Princess",
      "description": "The princess has been kidnapped by the evil sorcerer. Rescue her and bring her back to the castle.",
      "reward": "100 gold pieces"
    },
    {
      "name": "Defeat the Dragon",
      "description": "A dragon has been terrorizing the countryside. Defeat it and bring back its hoard as proof.",
      "reward": "500 gold pieces"
    }
  ],
  "locations": [
    {
      "name": "town square",
      "description": "The bustling town square is filled with vendors and townspeople going about their business."
    },
    {
      "name": "inn",
      "description": "The inn is a cozy place to rest and recover. The proprietor, Alice, is friendly and welcoming."
    },
    {
      "name": "dragon's lair",
      "description": "The entrance to the dragon's lair is guarded by a group of goblins. The lair itself is dark and filled with treasure."
    }
  ],
  "cutscenes": [
    {
      "name": "Intro",
      "script": "The kingdom of Araland is in peril. An evil sorcerer has seized control of the throne and taken the princess captive. As the bravest and most skilled warrior in the land, it falls to you to rescue her and restore peace to the kingdom."
    },
    {
      "name": "Defeat the Dragon",
      "script": "As you approach the dragon's lair, you can hear its fierce roar. You draw your sword and prepare to do battle. The fight is long and hard, but in the end, you emerge victorious. You take the dragon's hoard as proof of your victory and set off back to the kingdom."
    }
  ],
  "options": {
    "difficulty": "normal",
    "language": "english"
  }
}

In the next chapter we will see how we can fetch this data

🍠
https://6away.org/data.json