[Plugin] Hash table

Post your completed addons to share with the community

Post » Sun Nov 11, 2012 1:42 am

Update:

Add "expression:ToString" which could transfer hash table into JSON string.
It could assign mulit-parameters or no parameter.
- If there has no parameter, transfer current hash table saved in this hash table plugin.

- If there has parameters, like
[code]Hash.ToString("a", 10, "b", 20)[/code]
It will create a new hash table = {"a":10, "b":20}, then transfer it into JSON string.
User could use this method to create JSON string of hash table in an single expression. It might be useful to pass parameters with string index into official function plugin's "expression:Call".

Capx
rexrainbow2012-11-11 01:51:31
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Thu Jan 17, 2013 3:50 pm

Update

Add "action:copy" to update hash table by other hash table.
Sample capx
It provides 3 mode:
For example, the original content of hash table (hash table A) is
[code]{"a":1, "b":1, "c":1}[/code],
The copy source table (hash table B) is
[code]{"b":2, "c":2, "d":2}[/code]
1. "Overwrite from hash B"
The result after copying by this mode is
[code]{"a":1,"b":2,"c":2,"d":2}[/code]

2. "Merge new keys from hash table B"
The result after copying by this mode is
[code]{"a":1,"b":1,"c":1,"d":2}[/code]

3. "Clean then copy from hash table B"
The result after copying by this mode is
[code]{"b":2,"c":2,"d":2}[/code]


The motivation of making this action is to be used in loading saving data (from webstorage, for example).
When the structure of saving data was changed, designer might need to check the valid of key (if the key did not existed, assign a default value) to make sure the compatible between new structure and old saving structure.

For example, the hash table A
[code]{"a":1, "b":1, "c":1}[/code],
is the old saving structure, and the hash table B
[code]{"b":2, "c":2, "d":2}[/code]
is the new structure,
Designer need to use a condition to check if the saving data had key "d", return 2 and write into hash table A if "d" is not inside.

Now designer could use mode 2 to fill the new key from hash table B, so that designer could get value without checking valid.rexrainbow2013-01-17 15:58:14
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Tue Jan 29, 2013 11:01 pm

since nobody answered my in my "how to.." post i might as well take it to the source;)

i'm a noob trying to hack an app together that uses data from TMDB's API but i can't figure out how to make the results it returns usable in C2.

from what i read the hash table plugin is the best bet for working with JSON in C2.. but i cant get it to work :(

lets say i make a search request for a person like that:
http://api.themoviedb.org/3/search/person?api_key=MYAPIKEY&query=spielberg

what it gives me is:
{"page":1,"results":[{"adult":false,"id":488,"name":"Steven Spielberg","profile_path":"/jRWARxzljSY8SbOKTludOSECdk7.jpg"},{"adult":false,"id":8700,"name":"Sasha Spielberg","profile_path":null},{"adult":false,"id":23965,"name":"Anne Spielberg","profile_path":null},{"adult":false,"id":54127,"name":"David Spielberg","profile_path":null}],"total_pages":1,"total_results":4}

so right now i have a text input field wich modifies the search term of the request URL and the ajax object can request the the data from that URL no problem and from there i can load it into whatever i want.
Now i'm stuck though.. nothing seems to want to work. i don't even get the "id" keys to work with me..

my goal here is to get all the resulting persons names shown and made clickable in C2.

any ideas where to look?

thanks,
Alan
B
6
Posts: 20
Reputation: 904

Post » Tue Jan 29, 2013 11:58 pm

@AlanSmithee

1. get total result count
2. use for loop to get each item by expression: Hash.AtKey
Capx
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Wed Jan 30, 2013 2:52 pm

that works like a charm! thanks a lot..

now i just have to really understand it;)
B
6
Posts: 20
Reputation: 904

Post » Thu Jan 31, 2013 3:08 am

i've been playing a little with it.
the preview export's performance gets slower and slower within a very short time..

is that because the loop keeps going on?

dropbox.com/s/n2uy0zr91yqw5fy/tmdbapitest.capx since i cannot post linksAlanSmithee2013-01-31 03:14:20
B
6
Posts: 20
Reputation: 904

Post » Thu Jan 31, 2013 4:04 am

@AlanSmithee

In this capx, you use AJAX to get data from network. It need some times (not immediately).
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Thu Jan 31, 2013 10:50 am

sure, but should it get slower and slower even if you don't make new requests?AlanSmithee2013-01-31 10:51:12
B
6
Posts: 20
Reputation: 904

Post » Thu Jan 31, 2013 3:11 pm

@AlanSmithee

Hum... I run this capx many times , but I can not feel it become slower, do I miss something?
B
97
S
22
G
177
Posts: 4,111
Reputation: 103,525

Post » Fri Feb 01, 2013 11:01 pm

So I can't have multiple json's loaded into multiple hash objects? each hash object having a different name.
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,627

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests