GameMaker Problems with the manual

HayManMarc

Member
Does this make sense to you? It's really making me confused.

Copy/pasted from the manual:



-----------------------------------------------------------
Syntax:
Code:
json_stringify(val)
ArgumentDescription
valThe reference value for a struct or array to convert into a JSON string


Returns:

string



Example:
Code:
var _contents = {
version : "1",
data: {
webSocket : 1,
ipv4Address : "95.39.220.218",
ipv6Address : "0000:0000:0000:0000:0000:ffff:5f27:dcda",
header : "You are receiving a packet",
body : "This packet is empty and only for testing",
},
};
packet = json_stringify(map);
The above code will convert the "_contents" struct into a JSON string and store the string in a variable. The actual string would be like this:

{ "version": "1", "myObj": { "header": "You are receiving a packet", "webSocket": 1, "body": "A packet of cheese and onion crisps", "ipv4Address": "95.39.220.218", "ipv6Address": "0000:0000:0000:0000:0000:ffff:5f27:dcda" } }




------------------------------------------------------
Up there, at the end of the example code, is "packet = json_stringify(map);" Where is "map"? What is that referencing? Shouldn't it be "_contents" instead of "map" for this example?
Also, I'm trying to make sense of that last bit, after it says "The actual string would be like this:" Where does "myObj" come from? And "A packet of cheese and onion crisps"?

All of this just doesn't line up correctly to me. Or I'm just really dense and can't follow it? I'm trying to learn this to implement a save system, and I keep running into these types of confusing things in the manual. Makes learning this stuff a lot harder.
 

TsukaYuriko

☄️
Forum Staff
Moderator
That's probably supposed to be "packet = json_stringify(_contents);"... please file a ticket so it can get fixed. :) Not sure where myObj comes from, as it certainly shouldn't, and probably doesn't come from anywhere or end up anywhere in the result. Seems like when this was last changed, only half of it was updated.
 

Spam1985

Member
I often find the manual's explanations and examples to be confusing and difficult to understand! Some of the topics on there I can read 100 times and still not "get it". In such cases, I have to hope that Google turns up something to demystify it a bit. Failing that, it's off to the Discord help channel or the forums!
 
Top