我正在使用ubilabs的地理编码插件在移动应用中获取自动地址建议。
有谁知道我在哪里可以找到Google返回的不同JSON元素的最大长度?
给定以下JSON,以下字段的最大长度是多少:
long_name
和short_name
result.address_components
数组元素
results.formatted_address
results.geometry.location.lat
results.geometry.location.lng
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "48",
"short_name" : "48",
"types" : [ "street_number" ]
},
{
"long_name" : "Pirrama Road",
"short_name" : "Pirrama Road",
"types" : [ "route" ]
},
{
"long_name" : "Pyrmont",
"short_name" : "Pyrmont",
"types" : [ "locality", "political" ]
},
{
"long_name" : "NSW",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "AU",
"short_name" : "AU",
"types" : [ "country", "political" ]
},
{
"long_name" : "2009",
"short_name" : "2009",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "48 Pirrama Road, Pyrmont NSW, Australia",
"formatted_phone_number" : "(02) 9374 4000",
"geometry" : {
"location" : {
"lat" : -33.8669710,
"lng" : 151.1958750
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
"international_phone_number" : "+61 2 9374 4000",
"name" : "Google Sydney",
"place_id" : "ChIJN1t_tDeuEmsRUsoyG83frY4",
"scope" : "GOOGLE",
"alt_ids" : [
{
"place_id" : "D9iJyWEHuEmuEmsRm9hTkapTCrk",
"scope" : "APP"
}
],
"rating" : 4.70,
"reference" : "CnRsAAAA98C4wD-VFvzGq-KHVEFhlHuy1TD1W6UYZw7KjuvfVsKMRZkbCVBVDxXFOOCM108n9PuJMJxeAxix3WB6B16c1p2bY1ZQyOrcu1d9247xQhUmPgYjN37JMo5QBsWipTsnoIZA9yAzA-0pnxFM6yAcDhIQbU0z05f3xD3m9NQnhEDjvBoUw-BdcocVpXzKFcnMXUpf-nkyF1w",
"reviews" : [
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Simon Bengtsson",
"author_url" : "https://plus.google.com/104675092887960962573",
"language" : "en",
"rating" : 5,
"text" : "Just went inside to have a look at Google. Amazing.",
"time" : 1338440552869
},
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Felix Rauch Valenti",
"author_url" : "https://plus.google.com/103291556674373289857",
"language" : "en",
"rating" : 5,
"text" : "Best place to work :-)",
"time" : 1338411244325
},
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Chris",
"language" : "en",
"rating" : 5,
"text" : "Great place to work, always lots of free food!",
"time" : 1330467089039
}
],
"types" : [ "establishment" ],
"url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
"vicinity" : "48 Pirrama Road, Pyrmont",
"website" : "http://www.google.com.au/"
},
"status" : "OK"
}
答案 0 :(得分:1)
这是我遇到JavaScript问题的地方。变量定义含糊不清。因此,如果您的对象包含一个String元素,那么它将是String Variable的限制。
我找到了here,这是:
在JScript中,变体字符串变量具有与VBScript中相同的限制, 最多2 ^ 31个字符。
字符串文字(如"这是文字")有(IIRC)限制~2 ^ 10 (1024)个字符。
我的理解是这将是特定于浏览器的。 Internet Explorer将与FireFox不同;这将与Safari ...等不同所以有限制吗?我怀疑不是。 String变量可能只是一个Char数组。如果是这种情况,它可能没有任何限制,并且可以增长到Web浏览器可用的任何内存。
那么数组的限制是什么?找到this article说:
由于ToUint32抽象操作,根据ECMA-262第5版规范的数组的最大长度由无符号的32位整数绑定,因此最长的数组可能具有232-1 = 4,294,967,295 = 42.9亿个元素
这表明String变量可能最高可达42.9亿个字符。 Integer,Float,Double ......不同的野兽。
要回到您的问题,以下字段的最大长度,我建议您this:
JSON类似于XML等其他数据格式 - 如果您需要传输更多数据,则只需发送更多数据。整个JSON请求本身没有固有的大小限制。解析JSON请求的服务器将设置任何限制。 (例如,ASP.NET具有序列化程序的" MaxJsonLength"属性。)
信用转到Amber。