奇怪的API结果格式

时间:2013-12-03 17:40:54

标签: json google-translate

我找到了从Google翻译(非API)获取其他翻译的正确查询,但它是一种我从未见过的非常奇怪的格式。

http://translate.google.com/translate_a/t?client=t&sl=auto&tl=en&hl=en&sc=2&ie=UTF-8&oe=UTF-8&uptl=en&alttl=ru&pc=1&oc=1&otf=1&ssel=0&tsel=0&q=%D0%B2%D0%BC%D0%B5%D1%81%D1%82%D0%B5

[[["together","вместе","","vmeste"]],[["adverb",["together","along","in conjunction","along with","teamwise"],[["together",["вместе","друг с другом","одновременно","воедино","сообща","заодно"],,0.472366542],["along",["вдоль","вместе","вперед","с собой","по длине","дальше"],,0.0944792554],["in conjunction",["вместе","сообща"],,0.0089263292],["along with",["вместе"],,0.000561794208],["teamwise",["сообща","вместе"],,3.34055039e-06]],"вместе",4],["preposition",["including"],[["including",["включая","в том числе","вместе"],,0.00272237672]],"вместе",5]],"ru",,[["together",[4],1,0,999,0,1,0]],[["вместе",4,[["together",999,1,0],["along",0,1,0],["with",0,1,0]],[[0,6]],"вместе"]],,,[],64]

我能够使用代码

对此进行适度解码
    $kl = str_replace('[[','[',$kl);
    $kl = str_replace(']]',']',$kl);
    $kl = str_replace('[[','[',$kl);
    $kl = str_replace(']]',']',$kl);
    $kl = explode('],', $kl);
    $kl = $kl[1];
    $kl = str_replace('"',"",$kl);
    $kl = str_replace(",["," - ",$kl);
    $kl = str_replace(",",", ",$kl);
    $kl = str_replace('[','',$kl);

有没有人认识到这种格式或愿意尝试破译它?

1 个答案:

答案 0 :(得分:1)

它看起来像一个深度嵌套的JavaScript数组,用于递归自然语言解析。

enter image description here