Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. getting JSON data in much smaller way.

getting JSON data in much smaller way.

Scheduled Pinned Locked Moved JavaScript
jsontutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asif Rehman
    wrote on last edited by
    #1

    Normally JSON data is fetched in the following form from Web API etc. [ {"name" : "Steve", "Age": 76}, {"name": "Jeremy", "Age": 43} ] You can see that "name" and "Age" is repeating with every column. But I've seen a service getting data in this fashion. Which really shorten the JSON object something like that. [ columns: {"name", "age"} data: {"Steve",76},{"Jeremy",43} ] How to do it?

    N 1 Reply Last reply
    0
    • A Asif Rehman

      Normally JSON data is fetched in the following form from Web API etc. [ {"name" : "Steve", "Age": 76}, {"name": "Jeremy", "Age": 43} ] You can see that "name" and "Age" is repeating with every column. But I've seen a service getting data in this fashion. Which really shorten the JSON object something like that. [ columns: {"name", "age"} data: {"Steve",76},{"Jeremy",43} ] How to do it?

      N Offline
      N Offline
      NAEEM2727
      wrote on last edited by
      #2

      well, you can tweak the Json a little,

      {
      "name" : ["Steve", "Jeremy"],
      "Age": [76,43]
      }

      looks greatly shortened..

      Kornfeld Eliyahu PeterK 1 Reply Last reply
      0
      • N NAEEM2727

        well, you can tweak the Json a little,

        {
        "name" : ["Steve", "Jeremy"],
        "Age": [76,43]
        }

        looks greatly shortened..

        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu Peter
        wrote on last edited by
        #3

        But you lost all the good in JSON... I would say that compressing the traffic will do better...

        Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

        A 1 Reply Last reply
        0
        • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

          But you lost all the good in JSON... I would say that compressing the traffic will do better...

          Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

          A Offline
          A Offline
          Asif Rehman
          wrote on last edited by
          #4

          Is there a good tutorial on compressing the traffic on JSON data.

          Kornfeld Eliyahu PeterK 1 Reply Last reply
          0
          • A Asif Rehman

            Is there a good tutorial on compressing the traffic on JSON data.

            Kornfeld Eliyahu PeterK Offline
            Kornfeld Eliyahu PeterK Offline
            Kornfeld Eliyahu Peter
            wrote on last edited by
            #5

            It is a definition of your web server IIS/Apache or whatever you use... In IIS for instance there is a compression icon you can use...https://technet.microsoft.com/en-us/library/cc771003%28v=ws.10%29.aspx?f=255&MSPPError=-2147217396[^]

            Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

            "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups