0

I'm using ubilabs' geocoding plugin to get automatic address suggestions in a mobile app.

Does anyone know where I can find the maximum lengths of the different JSON elements Google returns?

Given the following JSON, what are the maximum lengths of the following fields:

  • long_name and short_name in result.address_components array elements

  • 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"
    }
T J
  • 42,762
  • 13
  • 83
  • 138
user1126515
  • 1,133
  • 3
  • 17
  • 34
  • Your question is unclear. What do you mean by *the maximum lengths of the different JSON elements*? Like the character length? The number of objects? Please edit and clarify your question, provide an example. Make sure you have tagged it properly. – Twisty Jun 28 '16 at 20:34
  • Sorry about that. I think I've made the appropriate corrections – user1126515 Jun 29 '16 at 01:44

1 Answers1

-1

This is where I have issues with JavaScript. Variable definition is vague. So, if your object contains a element that is a String, then it would be the limit of a String Variable.

I found here, that this is:

In JScript, variant string variables have the same limit as in VBScript, up to 2^31 characters.

String literals (as in "this is a literal") have (IIRC) a limit ~2^10 (1024) characters.

My understanding is that this is going to be Browser specific. Internet Explorer is going to be different than FireFox; which will be different than Safari... etc. So is there a limit? I suspect not. It's possible that a String variable is simply a Char array. If this is the case, it may very well have no limit and can grow to whatever degree of memory is available to the web browser.

So what's the limit of an Array? Found this article that says:

the maximum length of an array according to the ECMA-262 5th Edition specification is bound by an unsigned 32-bit integer due to the ToUint32 abstract operation, so the longest possible array could have 232-1 = 4,294,967,295 = 4.29 billion elements.

This would suggest then that a String variable could potentially top out at 4.29 billion characters. Integer, Float, Double... different beasts.

To get back to your question, what are the maximum lengths of the following fields, I refer you to this:

JSON is similar to other data formats like XML - if you need to transmit more data, you just send more data. There's no inherent size limitation to the overall JSON request itself. Any limitation would be set by the server parsing the JSON request. (For instance, ASP.NET has the "MaxJsonLength" property of the serializer.)

Credit goes to to Amber.

Community
  • 1
  • 1
Twisty
  • 30,304
  • 2
  • 26
  • 45
  • The question is about any max lengths of the data google returns, not about json in general. I'm pretty sure they're not going to return a formatted_address that takes 4 GB. – wvdz Apr 02 '20 at 13:37
  • @wvdz in my experience, the Google API returns data in JSON. So the limits would be associated with JSON, in general. – Twisty Apr 02 '20 at 18:02