Custom authentication deserialization failed: Error converting value [SOLVED check discussion!]
AcidBear
✭
It will be really cool if someone explained to how to correctly serialize data in php files,that ment to be sended to client.What type of construction should i use? Construction - {"name":"value"} seems to not working:(
0
Comments
-
Issue is solved via including multiple arrays into single "value" block. PhP code looks like this:
$info[2]; $info[0] = (object)array('1'=>"$somedata"); $info[1] = (object)array('2'=>'woof'); $Train = (object)$info; if ($passnya==$password){ $login_info_success = array( "ResultCode" => 1, "Message" => "Success!", "Data" => $Train , ); $json_success = json_encode($login_info_success); echo $json_success;
After receiving the train packet decoding in c# looks like:public override void OnCustomAuthenticationResponse(Dictionary<string, object> data) { var keys = data.Keys; foreach (string j in keys) { Debug.Log(string.Format("ID -> {0} Name -> {1}", j, data[j])); var temps = (object[])data[j]; var tempos = (object[])temps[0]; Debug.Log(string.Format("IDHIDED -> {0} NameHIDED -> {1}", j, tempos[0])); if (j == "0") Debug.Log (string.Format("Data from train package Info[{0}] is {1}", j, data[j])); } }
I hope this will help you in your projects;)0