Skip to content
Advertisement

how to get value inside JsonObject

im trying this new method Ion. with PDO and I got stuck where I want to get value inside JsonObject. I previously used Volly with msqli but I find Ion. more organized and PDO more safe.

whenever I try to add any code to java its just break and don’t work as if no connection same with PHP so I got stuck

part where I’m stuck at is LOG_IN_SUCCESS as I need to get user id for session manager as $row doesn’t show in java only the case “LOG_IN_SUCCESS” i also added case”LOG_IN_SUCCESS “: case”0”:{code break;} but i didnt work

I tried to add new string for case”0″which contain user Id but code just break

java

JavaScript

php

JavaScript

JSON

JavaScript

Advertisement

Answer

$row become an attribue of the object $returnApp as an associative array. I think you try to pass only the suser_sids so it should be something like

JavaScript

so it will return as :

JavaScript

Alternatively you could use array_merge_recursive to include the row within our object (as one associative array) but i won’t store/pass user password unless really necessary.

EDIT: Another way you can/should do it, is to create an actual object instead of using an assocaitive array. Something like this will create an anonymous object that you can pass to json_encode the same exact way you are doing now (welcome to OOP):

JavaScript

You could even define such class but PHP being what it is, it will vreate the stdObject for you 😉

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement