Firebase Realtime Database

Last Updated: 25 June 2022

Read Data-Custom: Get JSON String

Enabling "Get JSON String" will get Data in the Original JSON format of Firebase.

The "ProUI-GridView JSON" option allows you to get data in a format that is compatible with the well-liked ProUI GridView Extension by Aekiro. This option would be great for setting up smooth-scrollable list or Leaderboard easily.

IMAGE: Note The differences in format between the Original JSON String and the new ProUI-GridView JSON String.

Read Data-Custom: Get Array-JSON String

NOTE: This feature works along with the Realtime-Database PRO Plugin.

Description


You can read any Array Data stored in Firebase Database Console in this format below:

An example of how the data will look like in Firebase Console (left),
Read action result when using Get Array JSON String (middle)
Read action result when using Get JSON String (right)

An Array-JSON String can also contain data in json format in cases like this:

An example of how the data will look like in Firebase Console (left),
Read action result when using Get Array JSON String (right)

How to Write Data in Array format


For this, you need the Realtime-Database PRO plugin.

Realtime-Database & the Array Plugin

You can also use Read Data-Custom's "Get Array-JSON String" option to get a json string that is supported by the Construct 3's Array Plugin.

This section describes when to and when not to use "Get Array-JSON String" option for Construct 3's Array Plugin.

When you DO NOT need Array-JSON String


In usual cases, you can store Construct 3's Array.AsJSON data as a single string for example like this:

As you can see above, the data gets stored in string format. This can be simply be read using the Read Data (Custom) action like this:

However what is the problem with writing an Array data as a single string? The answer is, you have less control over the array data string. If you need to change a single data in that array string, you will need to rewrite the whole array. For example, you want to change "Messi" to "Neymar". To do this you would need to rewrite the whole string and that would cost you unnecessary data usage.

Use this method if you don't have the Realtime-Database PRO plugin.


When you need Array-JSON String

NOTE: This feature works along with the Realtime-Database PRO Plugin.

As opposed to the method used above, to have more control over the stored Array data, and to save data usage, you can use this option.

First use the Write/Replace JSON/Array Data action using the Array.AsJSON data to write an array in this format:

How to write Array's JSON data (left)
An example of how the data will look like in the Firebase Console (right)

As you can see above, the data gets stored in our required format. This can be be read using the Read Data (Custom) action like this: