Обработка json в js: Unexpected token _ in JSON at position 0

409
12 января 2017, 07:19
window.addEventListener('message', function (event) {
        console.log(event.data);
        var data = JSON.parse(event.data || "");
})

При обработке выходит ошибка Unexpected token _ in JSON at position 0. Консоль выдает

{"method":"fireIdpEvent","params":{"type":"idpReady"},"rpcToken":"658136158.2131159"} {"id":"311-765297.9476886411","result":true,"rpcToken":"658136158.2131159"} {"id":"384-627086.2626135985","result":{"hint":"AJDLj6LqSaddIRJEetlVbQKYJPNIGbPkaaiVqbDzve-yv1VYOTBnnpKeRtyjLzSAAuAkecUpMSlxYjIQ9KH7d_1un4TnuEjXvg","disabled":true},"rpcToken":"658136158.2131159"} {"s":"oauth2relayReady:870738807","f":"oauth2relay1624275389","c":0,"a":[null],"t":"870738807","l":false,"g":true,"r":"oauth2relay1624275389"} {"s":"ready:481579161","f":"apiproxydb27477e80ec6bf8cc9b74d291432674e05affe30.6590493341741102","c":0,"a":[],"t":"481579161","l":false,"g":true,"r":"apiproxydb27477e80ec6bf8cc9b74d291432674e05affe30.6590493341741102"} {"s":"__cb","f":"apiproxydb27477e80ec6bf8cc9b74d291432674e05affe30.6590493341741102","c":2,"a":[1,"{\"gapiRequest\":{\"data\":{\"body\":\"{\\\"version\\\":\\\"v1\\\",\\\"servicePath\\\":\\\"\\\",\\\"kind\\\":\\\"discovery#restDescription\\\",\\\"rootUrl\\\":\\\"people.googleapis.com/\\\",\\\"name\\\":\\\"people\\\",\\\"resources\\\":{\\\"people\\\":{\\\"methods\\\":{\\\"getBatchGet\\\":{\\\"flatPath\\\":\\\"v1/people:batchGet\\\",\\\"path\\\":\\\"v1/people:batchGet\\\",\\\"id\\\":\\\"people.people.getBatchGet\\\",\\\"description\\\":\\\"Provides information about a list of specific people by specifying a list\\\\nof requested resource names. Use `people/me` to indicate the authenticated\\\\nuser.\\\",\\\"response\\\":{\\\"$ref\\\":\\\"GetPeopleResponse\\\"},\\\"parameterOrder\\\":[],\\\"httpMethod\\\":\\\"GET\\\",\\\"parameters\\\":{\\\"requestMask.includeField\\\":{\\\"description\\\":\\\"Comma-separated list of fields to be included in the response. Omitting\\\\nthis field will include all fields except for connections.list requests,\\\\nwhich have a default mask that includes common fields like metadata, name,\\\\nphoto, and profile url.\\\\nEach path should start with `person.`: for example, `person.names` or\\\\n`person.photos`.\\\",\\\"format\\\":\\\"google-fieldmask\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"},\\\"resourceNames\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"The resource name, such as one returned by\\\\n[`people.connections.list`](/people/api/rest/v1/people.connections/list),\\\\nof one of the people to provide information about. You can include this\\\\nparameter up to 50 times in one request.\\\",\\\"type\\\":\\\"string\\\",\\\"repeated\\\":true}},\\\"scopes\\\":[\\\"googleapis.com/auth/contacts\\\",\\\"googleapis.com/auth/contacts.readonly\\\",\\\"googleapis.com/auth/plus.login\\\",\\\"googleapis.com/auth/user.addresses.read\\\",\\\"googleapis.com/auth/user.birthday.read\\\",\\\"www.googleapis.com/auth/user.emails.read\\\",\\\"www.googleapis.com/auth/user.phonenumbers.read\\\",\\\"googleapis.com/auth/userinfo.email\\\",\\\"googleapis.com/auth/userinfo.profile\\\"]},\\\"get\\\":{\\\"flatPath\\\":\\\"v1/people/{peopleId}\\\",\\\"id\\\":\\\"people.people.get\\\",\\\"path\\\":\\\"v1/{+resourceName}\\\",\\\"description\\\":\\\"Provides information about a person resource for a resource name. Use\\\\n`people/me` to indicate the authenticated user.\\\",\\\"httpMethod\\\":\\\"GET\\\",\\\"parameterOrder\\\":[\\\"resourceName\\\"],\\\"response\\\":{\\\"$ref\\\":\\\"Person\\\"},\\\"parameters\\\":{\\\"resourceName\\\":{\\\"description\\\":\\\"The resource name of the person to provide information about.\\\\n\\\\n- To get information about the authenticated user, specify `people/me`.\\\\n- To get information about any user, specify the resource name that\\\\n  identifies the user, such as the resource names returned by\\\\n  [`people.connections.list`](/people/api/rest/v1/people.connections/list).\\\",\\\"required\\\":true,\\\"type\\\":\\\"string\\\",\\\"pattern\\\":\\\"^people/[^/]+$\\\",\\\"location\\\":\\\"path\\\"},\\\"requestMask.includeField\\\":{\\\"description\\\":\\\"Comma-separated list of fields to be included in the response. Omitting\\\\nthis field will include all fields except for connections.list requests,\\\\nwhich have a default mask that includes common fields like metadata, name,\\\\nphoto, and profile url.\\\\nEach path should start with `person.`: for example, `person.names` or\\\\n`person.photos`.\\\",\\\"format\\\":\\\"google-fieldmask\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"}},\\\"scopes\\\":[\\\"googleapis.com/auth/contacts\\\",\\\"www.googleapis.com/auth/contacts.readonly\\\",\\\"www.googleapis.com/auth/plus.login\\\",\\\"www.googleapis.com/auth/user.addresses.read\\\",\\\"googleapis.com/auth/user.birthday.read\\\",\\\"googleapis.com/auth/user.emails.read\\\",\\\"googleapis.com/auth/user.phonenumbers.read\\\",\\\"googleapis.com/auth/userinfo.email\\\",\\\"googleapis.com/auth/userinfo.profile\\\"]}},\\\"resources\\\":{\\\"me\\\":{\\\"resources\\\":{\\\"connections\\\":{\\\"methods\\\":{\\\"list\\\":{\\\"httpMethod\\\":\\\"GET\\\",\\\"parameterOrder\\\":[],\\\"response\\\":{\\\"$ref\\\":\\\"ListConnectionsResponse\\\"},\\\"parameters\\\":{\\\"pageSize\\\":{\\\"description\\\":\\\"The number of connections to include in the response. Valid values are\\\\nbetween 1 and 500, inclusive. Defaults to
100.\\\",\\\"format\\\":\\\"int32\\\",\\\"type\\\":\\\"integer\\\",\\\"location\\\":\\\"query\\\"},\\\"requestMask.includeField\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Comma-separated list of fields to be included in the response. Omitting\\\\nthis field will include all fields except for connections.list requests,\\\\nwhich have a default mask that includes common fields like metadata, name,\\\\nphoto, and profile url.\\\\nEach path should start with `person.`: for example, `person.names` or\\\\n`person.photos`.\\\",\\\"format\\\":\\\"google-fieldmask\\\",\\\"type\\\":\\\"string\\\"},\\\"sortOrder\\\":{\\\"location\\\":\\\"query\\\",\\\"enum\\\":[\\\"LAST_MODIFIED_ASCENDING\\\",\\\"FIRST_NAME_ASCENDING\\\",\\\"LAST_NAME_ASCENDING\\\"],\\\"description\\\":\\\"The order in which the connections should be sorted. Defaults to\\\\n`LAST_MODIFIED_ASCENDING`.\\\",\\\"type\\\":\\\"string\\\"},\\\"syncToken\\\":{\\\"description\\\":\\\"A sync token, returned by a previous call to `people.connections.list`.\\\\nOnly resources changed since the sync token was created will be returned.\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"},\\\"pageToken\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"The token of the page to be returned.\\\",\\\"type\\\":\\\"string\\\"}},\\\"scopes\\\":[\\\"googleapis.com/auth/contacts\\\",\\\"googleapis.com/auth/contacts.readonly\\\"],\\\"flatPath\\\":\\\"v1/people/me/connections\\\",\\\"id\\\":\\\"people.people.me.connections.list\\\",\\\"path\\\":\\\"v1/people/me/connections\\\",\\\"description\\\":\\\"Provides a list of the authenticated user's contacts merged with any\\\\nlinked profiles.\\\"}}}}}}}},\\\"parameters\\\":{\\\"quotaUser\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.\\\",\\\"type\\\":\\\"string\\\"},\\\"pp\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Pretty-print response.\\\",\\\"type\\\":\\\"boolean\\\",\\\"default\\\":\\\"true\\\"},\\\"oauth_token\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"OAuth
2.0 token for the current user.\\\",\\\"type\\\":\\\"string\\\"},\\\"bearer_token\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"OAuth bearer token.\\\",\\\"type\\\":\\\"string\\\"},\\\"upload_protocol\\\":{\\\"description\\\":\\\"Upload protocol for media (e.g. \\\\\\\"raw\\\\\\\", \\\\\\\"multipart\\\\\\\").\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"},\\\"prettyPrint\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Returns response with indentations and line breaks.\\\",\\\"type\\\":\\\"boolean\\\",\\\"default\\\":\\\"true\\\"},\\\"uploadType\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Legacy upload protocol for media (e.g. \\\\\\\"media\\\\\\\", \\\\\\\"multipart\\\\\\\").\\\",\\\"type\\\":\\\"string\\\"},\\\"fields\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Selector specifying which fields to include in a partial response.\\\",\\\"type\\\":\\\"string\\\"},\\\"$.xgafv\\\":{\\\"description\\\":\\\"V1 error format.\\\",\\\"type\\\":\\\"string\\\",\\\"enumDescriptions\\\":[\\\"v1 error format\\\",\\\"v2 error format\\\"],\\\"location\\\":\\\"query\\\",\\\"enum\\\":[\\\"1\\\",\\\"2\\\"]},\\\"callback\\\":{\\\"description\\\":\\\"JSONP\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"},\\\"alt\\\":{\\\"enumDescriptions\\\":[\\\"Responses with Content-Type of application/json\\\",\\\"Media download with context-dependent Content-Type\\\",\\\"Responses with Content-Type of application/x-protobuf\\\"],\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"Data format for response.\\\",\\\"default\\\":\\\"json\\\",\\\"enum\\\":[\\\"json\\\",\\\"media\\\",\\\"proto\\\"],\\\"type\\\":\\\"string\\\"},\\\"key\\\":{\\\"location\\\":\\\"query\\\",\\\"description\\\":\\\"API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.\\\",\\\"type\\\":\\\"string\\\"},\\\"access_token\\\":{\\\"description\\\":\\\"OAuth access token.\\\",\\\"type\\\":\\\"string\\\",\\\"location\\\":\\\"query\\\"}}}\",\"headers\":{\"date\":\"Tue, 10 Jan 2017 10:38:53 GMT\",\"content-encoding\":\"gzip\",\"server\":\"ESF\",\"vary\":\"Origin, X-Origin, Referer\",\"content-type\":\"application/json; charset=UTF-8\",\"cache-control\":\"private\",\"content-length\":\"1874\"},\"status\":200,\"statusText\":\"\"}}}"],"t":"481579161","l":false,"g":true,"r":"apiproxydb27477e80ec6bf8cc9b74d291432674e05affe30.6590493341741102"}_FB_f27f80e79a643b4data&logged_in=true&xd_action=proxy_ready
READ ALSO
Объясните работу функции, пожалуйста! [требует правки]

Объясните работу функции, пожалуйста! [требует правки]

как эта функция отсортировала массив по длине его элементов?

223
Остановка (пауза) видео Youtube

Остановка (пауза) видео Youtube

Помогите чайникуСитуация такова: модальное окно на CSS, в нем карусель видео с ютуба, при закрытии модали - воспроизведение продолжается

702
Задачка с сортировкой массива

Задачка с сортировкой массива

Есть такой массив объектов

287