I have a .json file with valid data. I want to host it online and use the live url in my app. I tried putting the json file in drop box and tried to verify the json data on http://jsonformatter.curiousconcept.com site but it shows "JSON data URL does not contain JSON data" Is there any other way can I achieve this? Thanks.
-
So, you have valid JSON data, something is telling you you don't, and you aren't sharing the JSON? – Aug 29 '13 at 20:37
-
Have you generated the share link so you can indeed access this as plain text from visiting a URL – Daddy Aug 29 '13 at 20:38
-
@nil https://www.dropbox.com/s/okspzncwy8f5vld/reports.json – Obj-Swift Aug 29 '13 at 20:40
-
You need to share the raw data URL, not the Dropbox share link. I'm not sure how to do it, tho. – Carlos Agarie Aug 29 '13 at 20:43
-
@agarie thats what the question is.. – Obj-Swift Aug 29 '13 at 20:44
-
2Just get hosting and put it there. This is not what Dropbox is for. – Aug 29 '13 at 20:52
-
I was told it could be done. But right now hosting seems like the only solution..Thanks – Obj-Swift Aug 29 '13 at 20:57
-
Solution https://stackoverflow.com/a/50667231/1179638 – Atul Bhardwaj Jun 03 '18 at 14:07
7 Answers
You can still use Dropbox if you don't want to pay for a hosting provider or if you just want to test your app before paying for one.
To do this, you need to replace the www.dropbox.com
part of the URL with dl.dropboxusercontent.com
as is said in this Dropbox article.
I'm mainly leaving this answer for the future, as this can be useful for other people (me included).

- 3,952
- 1
- 26
- 38
This is exactly the problem I wanted to solve with http://www.myjson.com An easy and simple solution to hosting JSON.

- 181
- 1
- 3
-
-
That's a very unsafe approach. As far as I understand anybody can modify anybody else's JSON. – Grozz Mar 28 '15 at 05:21
-
1
-
@AshishSajwan I think no. Use this link https://stackoverflow.com/a/50667231/1179638 – Atul Bhardwaj Jun 03 '18 at 14:06
Okay, so you want to host a static JSON file on a webserver so an iOS app can open and parse it. There are a couple of steps and a slight learning curve but from what I'm reading this may help you.
Step 1: Verify that your JSON is valid since it appears that there's some confusion. Open the JSON in a text-editor like notepad. Copy it and paste it in the text area at this site:
If you get a parse error - find the line and edit. If you can't do this or the JSON is valid - stop and resolve this problem.
Step 2: While you could use dropbox to do this its not a good idea for a real app. Get a web host. Depending on your basic skill level you can use a cloud provider like Amazon, Heroku, etc. Based on this question - I'd recommend a basic ftp site. There are a ton of free/cheap webhosts.
The only thing you'll want to watch out with a "free plan" for is that they don't inject ads into your pages. (I'm looking at you GoDaddy.)
Step 3: (assuming you have an iOS app setup)
Add AFNetworking to your project and set up a AFJSONOperation.
And use the following code:
NSURL *url = [NSURL URLWithString:@"http://www.foo.com/bar.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
NSLog(@"JSON: %@", JSON);
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"error: %@ response: %@", error, response);
}];
[operation start];
Edit: removed link to Dropbox article. Added cheap webhost options.

- 9,211
- 17
- 48
- 69

- 1,098
- 11
- 28
-
Thanks. I used x10 web hosting and its working fine now. Thanks for detailed explanation.. – Obj-Swift Aug 29 '13 at 21:54
You can save your JSON here https://quarkbackend.com - free json hosting
This tool let you manage your files and the urls will not change after updating the file

- 71
- 1
Other than myjson.com
, You can host it in pastebin.com
and use the "Raw
" link to access it. Once advantage of pastebin.com
over myjson.com
is that you can set a expiry period after which it will be auto deleted.

- 4,890
- 2
- 27
- 27
Drop box is not an ideal solution for this. I would use S3 or something of that nature.

- 3,387
- 1
- 18
- 31
-
There are a bunch of good resources for this, here is one: http://chadthompson.me/2013/05/06/static-web-hosting-with-amazon-s3/ – Patrick Tescher Aug 29 '13 at 20:41
Step 1: Create a GitHub Gist account.
Step 2: Create a new Gist file with your JSON content and get the raw URL
For Instance: "https://gist.githubusercontent.com/YOUR_ACCOUNT_NAME/0df1fa45aa11753de0a85893448b22de/raw/YourData.txt";
Step 3: Retrieve the file contents from your app by invoking the WebService in GET request mode.

- 9,387
- 4
- 43
- 48