How do I load json from ajax request

Get help using Construct 2

Post » Sat Jan 17, 2015 1:00 pm

i am currently using the xml plugin to load my variables when using ajax requests and it works fine but but the xml data is much larger in size so since im aiming for the mobile market i want to minimize the data transfer size.ad having a json plugin that works exactly like the xml plugin would help to minimize the data size.

is there a json plugin for this?
B
9
S
2
Posts: 76
Reputation: 709

Post » Sun Jan 18, 2015 11:15 am

or is there maybe a usable workaround?
B
9
S
2
Posts: 76
Reputation: 709

Post » Sun Jan 25, 2015 7:30 pm

@ashley: you wrote earlier that this feature was planned but no ETA, do you have an update on this task?
B
9
S
2
Posts: 76
Reputation: 709

Post » Fri Feb 13, 2015 2:29 am

bump
B
9
S
2
Posts: 76
Reputation: 709

Post » Mon Feb 16, 2015 11:37 am

Try this...
https : // www scirra com /forum/plugin-json-import-export-generate-edit-inspect_t100042
B
2
G
1
Posts: 9
Reputation: 423

Post » Fri Feb 20, 2015 6:15 am

thanks, tried but this plugin loads json from an external file, i need to parse the Json data from AJax.lastdata
B
9
S
2
Posts: 76
Reputation: 709

Post » Fri Feb 20, 2015 7:35 am

@kaiko I created a plugin for personal use that might help you? Its a 3 dimensional associative array object (accessed via field name instead of indexed integer values). It can feel complicated at first but It supports loading raw JSON strings right into and easily accessing the data inside it which is what your looking for. I had the same issue as you but couldn't find a plugin I liked so i created this. I don't officially support it but its nothing more than a wrapper to access a 3 dimensional JavaScript variable for named storage purposes and perfectly stable. I use it in all my projects :) ..I attached the plugin and an example capx below if your interested?

Plugin
TRBLSM_storage.zip


Example capx usage r195
StorageExample.capx


store.png
You do not have the required permissions to view the files attached to this post.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Fri Feb 20, 2015 8:49 am

uhm ok, i tried your plugin,but in your example I cannot see how you acquire external data?
from an ajax request the complete dataset is in ajax.lastdata and i neeed to get it into some form of function so i can assign its values to variables see pic below.
You do not have the required permissions to view the files attached to this post.
B
9
S
2
Posts: 76
Reputation: 709

Post » Fri Feb 20, 2015 9:06 am

@kaiko you can take the Ajax.LastData and load it into the Storage object using the Merge Table action. When you're done you can dump the JSON string to text object to see it.

asd.png


The storage object is 3 dimensional so if your JSON object is one dimensional it will create top level names of "default".
Example
Storage.Get("default","default","myfield")

Think of it as a C2 Array that works more like a C2 Dictionary
You do not have the required permissions to view the files attached to this post.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sat Feb 21, 2015 12:52 am

ive tried this but storage doesnt print anything in text ,and when i debug i cant see that storage gets any data at all.
can you see where what im doing wrong?
You do not have the required permissions to view the files attached to this post.
B
9
S
2
Posts: 76
Reputation: 709

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, ratboy3, yolkgames and 34 guests