Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_hash

Plugin, ACE table, Discussion thread
Dependence: None

Introduction
Access JSON structure table.

Usage
Load
Sample capx
Call "Action:Load from JSON" to load content with JSON string. Dump the content by "Expression:AsJSON".
Call "Action:Clean all" to clean content and set to an empty object "{}". Load content by "[]" if user needs an array.

Read
There are two ways to get value by keys.
  • Expression:At( keys ) : Key string could be composed of multiple keys joined with ".".
  • Expression:At( keys , default_value ) : return default value if keys does not exist.
  • Expression:AtKeys( key0, key1, ... ) : put keys in each parameter.
For example, get value at root[b][c] is wrote by Expression:At( "b.c" ), or Expression:AtKeys( "b", "c" )
Retrieve keys
Sample capx
Retrieve keys and values in an object by "Condition:For each item", "Expression:CurKey", "Expression:CurValue". Get sub-item with a key by "Expression:CurValue( keys )". Loop index byExpression:Loopindex".
Put keys into official array
Sample capx
Here is another way to retrieve keys -
  1. Call "Action:Pick keys" to put all keys of an object into an official array.
  2. Read keys in this official array.
This solution is useful while there are a lot of keys. User could separate reading in multiple ticks.
Key exists
"Condition:Key exists" will return true if key exists.
Get random key
Sample capx
Get a random key from a table or an array by "Expression:RandomKeyAt".

Write
Call "Action:Set value" to set a number or string value at a key, or call "Action:Set JSON" to set a JSON object at a key. Parameter key could be multiple keys like "b.d".
Call "Action:Add to" to add a value to a key. (sample capx)
Remove key
Call "Action:Remove key" to remove a key.
Build JSON structure
It is recommended to use rex_json_builder plugin to build JSON structure.
Merge
Sample capx
Call "Action:Merge" to merge another JSON content.

Array operation
There are some actions for array operations.
  • Action:Sort (sample capx)
  • Action:Shuffle (sample capx) : change the order of items in an array
  • Action:Push JSON (sample capx) : add an item into an array
Querying
It is recommended to use rex_taffydb plugin to query items.

Save load
This plugin supports official save/load.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About