PHP returns JSON data to android

Source: Internet
Author: User
To describe your problem, I read a piece of JSON data from the PHP API on android and found that there was always an error. The error is as follows: {code ...} then I checked the JSON data on the webpage and found no error. That is to say, the PHP side returns JSON data normally, and an error occurs on the android side ....
  1. Describe your problem
    In this case, I read a piece of JSON data from the PHP API on the android client and found that there was always an error. The error is as follows:

02-13 21:06:15.313 13317-13317/? E/onError: unexpected end of stream on okhttp3.Address@eb5a1980

Then I checked the JSON data on the webpage and found no error. That is to say, the PHP side normally returns JSON data
Then an error occurs on the android client.

Then I suspect that the JSON data volume is too large ..
I increased the JSON data volume at and found that the data received by android was normal at the beginning... It's strange. When a certain amount of data arrives, I find that the JSON data output by Logcat is incorrect...

But the JSON data is not complete, that is, the data is truncated... So this error occurs: unexpected end of stream on okhttp3.Address @ eb5a1980, PS. I use the Okhttp3 network access library...
I am using a POST request. Baidu says there is no limit on the transmission volume... There won't be much data at this point...
How can this problem be solved?
Also, I want to return Chinese characters. How can I change it to \ u ...?

Reply content:
  1. Describe your problem
    In this case, I read a piece of JSON data from the PHP API on the android client and found that there was always an error. The error is as follows:

02-13 21:06:15.313 13317-13317/? E/onError: unexpected end of stream on okhttp3.Address@eb5a1980

Then I checked the JSON data on the webpage and found no error. That is to say, the PHP side normally returns JSON data
Then an error occurs on the android client.

Then I suspect that the JSON data volume is too large ..
I increased the JSON data volume at and found that the data received by android was normal at the beginning... It's strange. When a certain amount of data arrives, I find that the JSON data output by Logcat is incorrect...

But the JSON data is not complete, that is, the data is truncated... So this error occurs: unexpected end of stream on okhttp3.Address @ eb5a1980, PS. I use the Okhttp3 network access library...
I am using a POST request. Baidu says there is no limit on the transmission volume... There won't be much data at this point...
How can this problem be solved?
Also, I want to return Chinese characters. How can I change it to \ u ...?

\ U is a Chinese unicode code

Capture packets to see where the problem is

There is no limit on the transmission volume, but is there a limit on the called interfaces?

If there is a chrmoe browser on the computer, you can install a json-handle plug-in, you will know that the json format is incorrect, and automatic json Parsing is convenient to view

The json_encode function and the JSON_UNESCAPED_UNICODE parameter are displayed as Chinese characters.
I don't know what your business is. If the data volume is too large, it will be processed by page.

\ U is unicode encoding. During json encoding, Chinese characters are converted to unicode encoding. This is normal. From your perspective, the data is intercepted, you can check whether the method you receive data does not intercept the returned data. It is best to install a packet capture software or access the data in the browser to check whether the data returned by the server is normal. If it is normal, it is the problem of receiving data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.