Hmm, I was trying the functions of the JSON plugin, toJSON and toJSONFile both works perfectly.
I was trying the fromJSON, it doesn't work properly.
Here's what I tried:-
exec local file = file("data.json","r"); print( fromJSON(file) );
Here's what data.json contains:-
{
"name": "[0.4]BABAKAKAN's Server",
"ip2": "babakakan.noip.me"
}
I created that JSON code using toJSONFile.
Here's the error which got produced when I ran the 1st code( fromJSON ):-
Error in 'fromJSON': Wrong number of arguments or invalid argument type
I tried this too:-
print( fromJSONFile("data.json") );
The following error/output I got:-
(table:0x000....)
Can someone tell me my mistake?
This is VC:MP's squirrel scripting board, you can only ask for squirrel help.
go away hush
Quote from: Xmair on Dec 06, 2015, 12:04 PMThis is VC:MP's squirrel scripting board, you can only ask for squirrel help.
go away hush
That plugin is also for VCMP and it is used with VCMP Squirrel scripts.
and if not, where shall I ask?
Run a foreach loop and print all the stuff in that table which is getting returned.
How is that an error? It's printing what it is, a table.
Try printing an element.
local test = fromJSONFile("data.json");
if ( test ) {
print( test.name );
}
More precisely I was surprised you don't even know how to work with tables that you are asking that...
Quote from: Thijn on Dec 06, 2015, 09:58 PMHow is that an error? It's printing what it is, a table.
Try printing an element.
local test = fromJSONFile("data.json");
if ( test ) {
print( test.name );
}
Thanks!
Locked, marked as solved.