JSON server on Android - android

I'm new in Android development. I have a lot of file .JSON that I want to take by REST requests in my app. Is there a JSON local server for Android where I can save these file and do some REST requests?
Thanks

Go through with this url :-
https://github.com/typicode/json-server.

I stumbled to and used SyncAdapter and json-server to firebase and I treated android like a web-app
I noticed that the guide used uri and json parsing so I imported my fake rest db.json to firebase and used the link on https://console.firebase.google.com/project/new-firebase-app/database/data
...
final String rest = "https://new-firebase-app.firebaseio.com/people.json";
// Parse the pretend json news feed
String jsonFeed = download(rest);
JSONArray jsonPeople = new JSONArray(jsonFeed);
...
This might help.

Related

How to pass data from Android to Laravel

I'm currently working on an android project. In this project, I pass data name, message, and email to the server through a simple PHP code. But now I want to pass these data to the server through Laravel, because the project is in Laravel.
Android data
String name = params[1];
String message = params[2];
String mail = params[3];
And pass this data to Laravel. Here is the code. The folder in which this file is present. Apps/Http/ . Now how we write the android code to pass this data to route easily.
Route::get('/message/{userid}','MapController#sendalert');
Route::post('/mymessage','MapController#myalert');
It seems you already know how to post since you can post to "simple php". Now what you want is build an API with Laravel. Once ready you can post your data to a URL rather than a php file, like
POST
https://www.mywebsite.com/api/comments
And your controller will take over. There are several steps involved in this process with a lot of resources available online like these:
http://esbenp.github.io/2016/04/11/modern-rest-api-laravel-part-1/
https://www.codetutorial.io/laravel-5-rest-api-basic-authentication/
Those should get you started.

How can I interface an Android app with SQL Server?

This is my problem:
I have to make an Android app that recover some data from an existing database situated on a Microsoft SQL Server installation on Windows Server 2003. I don't know so much about server-side programming languages, so I'm searching on the Internet, and I've found that I have to use a Web Service between my app and the ASP Classic page that connect to the database.
I also found that I have to use SOAP to send data to the server with my app, using the ksoap2 library on Android, and I found how to configure it on the client side. But I can't find how to configure the WebService and which format is better for interfacing my app and the ASP Classic page.
It's very easy, actually. All what you need is to create a webservice which will display the results in JSON format. Then you need to run an HTTP request from your Android app in order the get a JSON array containing JSON objects and then you will have your data from your database.
For example: the webservice will have a function written in ASP with a SELECT statement. Before your return the result, you need to encode it in JSON. Check out JSON Encode (MSDN).
The Android app will connect to the web service link and simply retrieve the JSON encoded data. I'll put you in the right way. You just use a snippet like this one to get data from the web service:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://yourwebservice.aspx", new AsyncHttpResponseHandler() {
#Override
public void onSuccess(String response) {
JSONArray jarr = new JSONArray(response);
for(int i = 0; i < jarr.length(); ++i) {
JSONObject jobj = jarr.getJSONObject(i);
// Do your things...
}
}
});
Create a RESTful web service in Web API or WCF. Web API will communicate with the database and your Android application with communicate with the web service.

make android provide any request to symfony

My project is in symfony where I need to get some data from android. So I implemented json encoding on both parts but my web application does not receive the data from android. I found the android is being unable to send data to symfony..
The code for android where the web link is written is as follows:
JSONObject json = jsonParser.getJSONFromUrl("http://external.apostle.digibiz.com/web/app_dev.php/api/test", params);
What is the error ??

Send and retrieve Ruby on Rails query?

I don't know anything about Ruby, but I think what I'm trying to do is pretty simple. I have an app that needs to send a url query like this to a heroku database: http://dartmouth.heroku.com/dnd/search.json?query=sebastian, then receive the data that comes back and organize it for the user. How do I send and recieve a query like this?
EDIT: I downloaded Spring and added the rest template jar to my projects build path. I tried using this code:
String url = "http://dartmouth.heroku.com/dnd/" + dataBase + "json?query=" + searchContent;
RestTemplate rstTemplate = new RestTemplate();
PersonList pList = rstTemplate.getForObject(url, PersonList.class);
but "RestTemplate" is not recognized. Did I miss an installation step?
You need to start by making an HTTP request for the data and then parsing the results. I would suggest trying out the Spring Android library to accomplish this: http://www.springsource.org/spring-android
Check out the explanation here: http://mike.bailey.net.au/2011/02/json-with-ruby-and-rails/
You can use a plugin called HttpParty for sending the request. Ruby on rails will interpret the json response by using the json library. The example on the above mentioned page might make things clearer.

RESTlet tutorial application does not return Java Objects (JSON only)

I've been looking the source code available from the Restlet official tutorial.
I am trying to hit the Restlet server using the Android app from he tutorial adn I only get the JSON response, not the Java Object. I tried using all libraries and extensions, nothing works. When I hit the tutorial url though ( http://restlet-example-serialization.appspot.com/contacts/123) I get the desired response. Any ideas? BTW, I am just using the server (GAE) in the example, not the GWT frontend.
Use GSOn to convert json to java object. GSON you can get from google as its their code:
http://code.google.com/p/google-gson/
Other way:
Response res = client.handle(req);
ObjectRepresentation<Item> obj = new ObjectRepresentation<Item>(res.getEntity());
Item item = obj.getObject();

Categories

Resources