I have to take some information from a json file. The json file size is 450 KB. But i do not need all json file so i don't want to download json. The question is that is it possible to read n charachters or line by line from json file without download all file ? If it is possible how to do?
Asked
Active
Viewed 448 times
0
-
1`Range` header perhaps; http://stackoverflow.com/questions/15200266/can-i-use-the-http-range-header-to-load-partial-files-on-purpose – Alex K. Jun 09 '15 at 16:36
-
When you create that json file give your specific name to file. Read fileName and decide read or not read. – hurricane Jun 09 '15 at 16:38
-
And you want to do this clientside using XMLHttpRequest ? – adeneo Jun 09 '15 at 16:38
-
yes client side @adeneo – RockOnGom Jun 09 '15 at 16:40
-
If the server hosting the JSON allows it, a range header could be used, but I would probably use the webserver instead, where specifying the number of bytes to read is a lot easier, and then just do the ajax call to your own server. – adeneo Jun 09 '15 at 16:46
-
@adeneo it is not my server. – RockOnGom Jun 09 '15 at 16:51
-
@AlexK. i am trying to send range header request. – RockOnGom Jun 09 '15 at 16:52
-
Also see: [How can I find out whether a server supports the Range header?](http://stackoverflow.com/questions/15200266/can-i-use-the-http-range-header-to-load-partial-files-on-purpose) – Yogi Jun 09 '15 at 17:23
1 Answers
1
You could try the HTTP Range header.
This document defines HTTP/1.1 range requests, partial responses, and the multipart/byteranges media type. Range requests are an OPTIONAL
feature of HTTP, designed so that recipients not implementing this
feature (or not supporting it for the target resource) can respond as if it is a normal GET request without impacting interoperability.
Partial responses are indicated by a distinct status code to not be
mistaken for full responses by caches that might not implement the
feature.