I am parsing a JSON response (twitter api – cursor value) and what should be a string value seems to be a double value when I output it with PHP.
Any idea how I get the real string value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The curser value is too large for 32bit PHP installs to handle with json_decode. Someone sent me
preg_replace( '/next_cursor":(\d+)/', 'next_cursor":"\1"', $json );. Running that before json_decode will convert the json int to a string before conversion.Update: Twitter now provides next_cursor_str values that are strings instead of integers so using
preg_replaceis no longer needed.