• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REST controller wrong output

#1
[eluser]oskar_ha[/eluser]
Hi all.
I use REST server for GET request. When I try to output some strings value, I get wrong output.
Code:
$this->response(array('id'=>'012e0098'), 200);

output:
Code:
{"id":1.2e+99}
How to get correct ouput string?
Code:
{"id":"012e0098"}

#2
[eluser]oskar_ha[/eluser]
anyone?
please help me...

#3
[eluser]oskar_ha[/eluser]
hello?

#4
[eluser]InsiteFX[/eluser]
json_decode();

#5
[eluser]oskar_ha[/eluser]
[quote author="InsiteFX" date="1395226114"]json_decode();
[/quote]
Can you explain how to use this function for resolve my problem?
Thanks.

#6
[eluser]InsiteFX[/eluser]
json_decode will convert it back into an associated array which then you can get your parameter out of it for displaying

#7
[eluser]oskar_ha[/eluser]
[quote author="InsiteFX" date="1395246189"]json_decode will convert it back into an associated array which then you can get your parameter out of it for displaying
[/quote]

Did you mean:
Code:
$this->response(json_decode('{"id":"012e0098"}'), 200);

Still get:
Code:
{"id":1.2e+99}

Thanks but it's not working

#8
[eluser]InsiteFX[/eluser]
json_decode

#9
[eluser]oskar_ha[/eluser]
[quote author="InsiteFX" date="1395258958"]json_decode[/quote]
I don't understand. json_decode converts an json string into an array or object. but I don't have any json encoded string as input.

#10
[eluser]Tpojka[/eluser]
So json_encode it:
[code]
//$this->response(array('id'=>'012e0098'), 200);
echo json_encode(array('id'=>'012e0098'));
[code]

edit: don't just copy this, use correct quote marks instead


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.