How do I set JSON item 'true'

0 favourites
  • 6 posts
From the Asset Store
A fantastic package of 117 high-quality & game-ready sound effects for User Interface, Items, Power-Ups, and more!
  • Hi Guys,

    I am currently creating a quiz game and I want the questions to be pulled out of the JSON document automatically. Using the Load-JSON plugin I was able to load the text up no problems but i was wondering if anyone knew how to tell the JSON which of the answers are correct?

    Below is my currently JSON text with the first set of numbers being the question number, then the question (Q1) and then the set of answers.

    	"1": ["Q1", "1", "2", "3", "4"],
    	"2": ["Q2", "1", "2", "3", "4"],
    	"3": ["Q3", "1", "2", "3", "4"],
    	"4": ["Q4", "1", "2", "3", "4"]
    From reading forums and guides, it seems that I am suppose to add ':true' after the correct answer but everytime I try that I just get an 'Nothing Found' Message.
    Your help will be greatly appreciated as I am only starting to learn about ARRAY & JSON
  • If you have a static number of answers (and as I can see in your example there are always 4) then you can simply add 6th parameter which will determine which answer is correct.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • then compare the correct_index value (the #5 index slot in your array; or 6th slot) to the player's choice, like:

    if player_choice == JSON.array.At(5)

    then Set Text: "Correct!"

  • Thanks guys! I will give this a shot

  • ai4ns don't need another cell...

    just set your array like this:


    	"1": ["Q1", "1", "2", "3", "4"],....."1"=True
    	"2": ["Q2", "1", "2", "3", "4"],....."1"=True
    	"3": ["Q3", "1", "2", "3", "4"],....."1"=True
    	"4": ["Q4", "1", "2", "3", "4"]......"1"=True
    ..and then randomize  Answers position....
    like this:
  • Thanks korbaach really helpful! Thanks soo much!! I will give this a shot tomorrow when I jump back on this!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)