Hello use dancer 1.3132 I need to retun a json to my AngulasJS app come from my MySQL database but my json return "false" instead of false and "true" instead of true or 0/1 instead of true/false my @todo = database()->quick_select('ToDo',{ userId => $userId },{limit => 50} ); return \@todo; I try binay fields, varchar fields, bool fields ( return 0/1), tinyint( 0/1) do you have a idea ? or I need to parse @todo and change by myself ? [ { "Completed" : "false", "Id" : "11", "UserId" : "1", "Tache" : "my 1st task" }, { "Completed" : "true", "Id" : "12", "UserId" : "1", "Tache" : "aller chercher le chien" }, ]
On Mon, 2015-01-26 at 12:22 +0100, Hugues wrote:
I need to retun a json to my AngulasJS app come from my MySQL database but my json return "false" instead of false and "true" instead of true or 0/1 instead of true/false
You need to use a reference to 0 or 1 for it to be converted to a JSON boolean. For example: { string => "some string", boolean => \1, # This will be converted to true }
Expanding on Andrew's answer, the JSON module is used, this is what you can find in its documentation: [...] references to the integers 0 and 1, which get turned into false and true atoms in JSON. You can also use JSON::false and JSON::true to improve readability. Ciao, Flavio. 2015-01-26 12:22 GMT+01:00 Hugues <hugues@max4mail.com>:
Hello use dancer 1.3132 I need to retun a json to my AngulasJS app come from my MySQL database but my json return "false" instead of false and "true" instead of true or 0/1 instead of true/false
my @todo = database()->quick_select('ToDo',{ userId => $userId },{limit => 50} ); return \@todo;
I try binay fields, varchar fields, bool fields ( return 0/1), tinyint( 0/1)
do you have a idea ? or I need to parse @todo and change by myself ?
[ { "Completed" : "false", "Id" : "11", "UserId" : "1", "Tache" : "my 1st task" }, { "Completed" : "true", "Id" : "12", "UserId" : "1", "Tache" : "aller chercher le chien" }, ]
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
ok thanks all I 'm going to test bye Hugues. Le 26/01/2015 16:01, Flavio Poletti a écrit :
Expanding on Andrew's answer, the JSON module is used, this is what you can find in its documentation:
[...] references to the integers |0| and |1|, which get turned into |false| and |true| atoms in JSON. You can also use |JSON::false| and |JSON::true| to improve readability.
Ciao,
Flavio.
2015-01-26 12:22 GMT+01:00 Hugues <hugues@max4mail.com <mailto:hugues@max4mail.com>>:
Hello use dancer 1.3132 I need to retun a json to my AngulasJS app come from my MySQL database but my json return "false" instead of false and "true" instead of true or 0/1 instead of true/false
my @todo = database()->quick_select('ToDo',{ userId => $userId },{limit => 50} ); return \@todo;
I try binay fields, varchar fields, bool fields ( return 0/1), tinyint( 0/1)
do you have a idea ? or I need to parse @todo and change by myself ?
[ { "Completed" : "false", "Id" : "11", "UserId" : "1", "Tache" : "my 1st task" }, { "Completed" : "true", "Id" : "12", "UserId" : "1", "Tache" : "aller chercher le chien" }, ]
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (3)
-
Andrew Beverley -
Flavio Poletti -
Hugues