search

Home  >  Q&A  >  body text

javascript - How many properties can a json object have at most?

I have a question. If there are hundreds of thousands of attributes in my json object, will there be any problems with json?

PHP中文网PHP中文网2746 days ago627

reply all(4)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:41:25

    js should have no restrictions on it, but the performance of the computer is limited.
    I actually tested it:

    var obj={};
    for(var i=0;i<80000000;i++){
       obj[i]=i;
       if(i%1000==0){
              console.log(i);
           }
    }    
    

    My computer will crash when it reaches over 70 million.
    The more complex the keys and values ​​stored in the object, the smaller the number that can be accommodated.

    But in actual application, you definitely can’t do it like this!

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:41:25

    ... Then why do you use Json? It's hard to throw the data into the database and then use the backend to write a program to read the database. .

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:41:25

    Hundreds of thousands of properties. . . JSON itself does not have any restrictions on the number of attributes, but js processing may be very slow, or a single request may not be able to be accommodated through http transmission. . .

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:41:25

    The question is why do you put hundreds of thousands of attributes in a JSON. .

    reply
    0
  • Cancelreply