[Solved]Load and save to JSON

Get help using Construct 2

Post » Mon Feb 24, 2014 10:22 pm

@Guizmus

Just want to say i have read this thread and not only learned stuff myself but have been amazed at your patience :-). Thanks
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Tue Feb 25, 2014 6:40 am

@spongehammer
Happy to help ^^ I didn't think I coumld still teach you something though, you seem to know C2 like the back of your hand :)
As for patience, when the one needing help does efforts to try and understand what you explain, it's always easier !
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Wed Feb 26, 2014 9:03 am

Sorry for the day silence, I've been absent (dentist and birthday and stuff xD) Indeed @Guizmus , patience is something you certainly have :) Thanks alot, for helping me understand C2 a bit better :)

And I have to ask for a little bit more patience...

Code: Select all
{"c2array":true,"size":[2,1,1],"data":[[["test1"],["test2"]]]}


This is my JSON as I am still figuring out the ins and outs before I push this to our development cycle. The array is named List, and List.At(1) returns 0 instead of the expected "test2" and I can't for the life of it seem to figure out what is going wrong :x

EDIT: Scrap that out, I figured it out (seems that Construct refuses to load the array if I use one bracket instead of two)
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Wed Feb 26, 2014 2:33 pm

I do, however, have another question: Does C2 cary a function to convert JSON to a supported format?
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Wed Feb 26, 2014 2:45 pm

What do you mean by "supported format" ?
Something that would format your json if not formated right in order to load an array from it ? no.

A way to get data from a given JSON without loading it in an object ? yes : javascript. The system object has "execJS" action, that will execute a JS string and return the return value (if used inline). In this context, if X is your JSON string, you can execJS("var a ="&X). This will set the window.a variable to the content of the JSON. You will then be able to access data from a using execJS again.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Mon Mar 03, 2014 8:28 am

I got a function, I want to import this into C2 and parse a file into this, saving it into an array.

Is there a way to:

1. Import a whole javascript function
2. Have an file select dialogue

I already have an HTML file select page with a converter function that converts a JSON file with our datastructure into a file that C2 understands. This is running on qdekoster.nl/testing.html (can't post complete urls yet) In the source code of this page, the function is also visible.
B
7
S
2
G
2
Posts: 46
Reputation: 769

Previous

Return to How do I....?

Who is online

Users browsing this forum: max2612 and 5 guests