Код: Выделить всё
"commandMetadata":{"webCommandMetadata":{"url":"/list?v=FA0ORzV4jfw\u0026pp=QAFIAQ%3D%3D","webPageType":"WEB_PAGE_TYPE_WATCH","rootVe":3832}},"watchEndpoint":{"parentId":"FA0ORzV4jfw","params":"EAEYAdoBBAgBKgA%3D","playerParams":"QAFIAQ%3D%3D"
Хотя мой код в большинстве случаев работает нормально, но, к сожалению, на некоторые запросы (периодически) кажется, что приходит ответ в шестнадцатеричном формате Юникода, например
Код: Выделить всё
\x22commandMetadata\x22:\x7b\x22webCommandMetadata\x22:\x7b\x22sendPost\x22:true,\x22apiUrl\x22:\x22\/tmapi\/v1\/like\/like\x22\x7d\x7d,\x22likeEndpoint\x22:\x7b\x22status\x22:\x22LIKE\x22,\x22target\x22:\x7b\x22parentId\x22:\x22O3PGXbXja4g\x22\x7d,\x22likeParams\x22:\x22
Я пытался преобразовать строку в utf-8, но, похоже, это не работает
Код: Выделить всё
String decodedResponse = new String(rawResponse.getBytes(), StandardCharsets.UTF_8);
Код: Выделить всё
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
// Read the response line by line
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
String rawResponse = response.toString();
//LOG.info("rawResponse {}",rawResponse);
String decodedResponse = new String(rawResponse.getBytes(), StandardCharsets.UTF_8);
LOG.info("decodedResponse {}",decodedResponse);
String regex = "\"parentId\":\"([^\"]+)\"";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(decodedResponse);
Буду очень признателен за помощь.
Подробнее здесь: https://stackoverflow.com/questions/791 ... ng-in-java
Мобильная версия