views:

287

answers:

5
+3  Q: 

JSON limitation?

Hello,

I would like to know if JSON with AJAX has a limitation to the amount of data an outgoing and returning parameter can carry?

I would like to be able to send and return from the server a file with 10,000 lines, as a string. How should I achieve this task? Will a single parameter will be able to hand this?

EDIT: My client is JavaScript and my server PHP.

Thank you.

+2  A: 

HTTP POST requests have no (reasonable) size limitations.

However, if you're posting more than 100MB of data, it's unlikely to work reliably.

SLaks
+3  A: 

Similar question

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.)

NebuSoft
+5  A: 

JSON does not inherently have a limit as to the amount of data it can transmit or a limit on its recursion depth. This depends on your application server.

If you're using JSONSerialization with C#, the limit on the amount of data is set to pretty low. You can overwrite that by putting the following code snippet in your Web.config.


<system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
            </webServices>
        </scripting>
    </system.web.extensions>

You probably DON'T want to be sending around 10 000 lines via AJAX if you can avoid it (break it up into smaller requests or use paging).

apandit
+1  A: 

I think the biggest weakness of Json is the semantics.

Otherwise there is no limitations if you are using HttpPost. But of course for better user experience, keep it simple and less.

More : http://blogs.sun.com/bblfish/entry/the_limitations_of_json

Braveyard
+1  A: 

you should break up the string into bits and do multiple ajax requests until string is complete. Keep appending the string bits temporarily to a file and then put the file contents inside of your database once the requests are complete.

resopollution
Sound like you've done something like this before, can you recommend of the size of each request? My files is 10,000 lines long and each line contains ~150 chars. (I'm using javascript and php)
thedp
For me I always keep it under 1mb per request.
resopollution
1mb? Even for sending a request with a parameter of 1mb?
thedp