Having understood what json is, I want to compare it with something and only a serialized object comes to mind. But I have long been tormented by the question, which is time to ask - is it possible to store the serialized object in a file on the server. If so, which file extension is best stored.

Addition:

@ShockWave : Thank you so much! But I have a few more questions - I see the lines again :) what makes you ask - is it possible to serialize an object in as3 into a binary array and transfer it to the server and write to something? That is, if the object is serialized in xml, then as far as I know, this is very bad especially for mobile devices (it eats up a lot of memory), json would be preferable, but as it turned out, it is just like the xml string, the value of which then needs to be converted to types (I'm talking about simple types). I didn’t ever do it myself, but I heard that objects can be serialized into binary formats that are transmitted over the network faster and when deserializing they retain property types and in general the object itself can be reduced to a specific type. And I want to know about the binary serialization as follows: is it possible to save a binary array on the server, is it much faster transmitted over the network (compared to xml) and did you or perhaps read somewhere about comparing the speed of deserialization of binary data compared to the speed of string conversion json to an object and casting the types of this object using the second optional parameter of the parse method? text in italics

  • - like AMF and RTMP, from binary transfer protocols, but I did not encounter it ( fluorinefx.com ) - naturally the binary is transferred faster and eats less resources - how to store such data on the server is not up to date, like everything is being parsed again and into the database - I met at least two more formats, maybe later I’ll google - ShockWave

2 answers 2

You can store, for example in the database for this you need:

  • from the object build a SQL query containing the fields of this object, serialize

here is an approximate way:

var serialized:String = "UPDATE `cards` SET `apartment` = '+roomCombo.selectedIndex+ `first_name` = '+fName.text+ `second_name` = '+sName.text+ `third_name` = '+tName.text'+ `date_in` = '+dateIn.text+' 00:00:00'+ `date_out` = '+dateOut.text+' 00:00:00'+ `sex` = '+sexCombo.selectedIndex'; 

In the opposite case, when receiving an object from the server, we build a string from the result of the request, and convert it into our object in a flash application.

  var cardModel:XML = new XML("<item>"+ "<apartment>1</apartment>"+ "<first_name>*</first_name>"+ "<second_name>*</second_name>"+ "<third_name>*</third_name>"+ "<date_in>2014-04-06 00:00:00</date_in>"+ "<date_out>2014-04-06 00:00:00</date_out>"+ "<sex>0</sex>"+ "</item>"); 

On the server, PHP can do this easily:

The following example accepts save requests to the database (CREATE, UPDATE), and sends objects to the client (SELECT FROM)

  <?php mysql_connect('127.0.0.1:3306', 'root', '1'); mysql_select_db('booking'); $sql = $_POST["sql"]; if ( $sql == null ) $sql = 'SELECT * FROM `cards`'; $result = mysql_query($sql); if ( is_bool($result) ) die($result); echo "<data>\n"; while($data = mysql_fetch_assoc($result)) { echo "<item>\n"; foreach($data as $key => $value) { echo "<$key>$value</$key>\n"; } echo "</item>\n"; } echo "</data>"; ?> 
  • Completed the question. Thank! - vas

Use AMF. It is native for Flash and compact (even the zip itself when transferring). What and how to do it on the server depends on your tasks and the server platform used.