Reputation: 562
At the moment, I've got a JSON file with content looking like this:
{
"username": "test",
"someNumber": 100
}
I'm using JSON.Net to fetch the .JSON file from a webserver - C#:
var http = new HttpClient();
http.MaxResponseContentBufferSize = Int32.MaxValue;
var response = await http.GetStringAsync(URI);
var result = JsonConvert.DeserializeObject<DatClass.Result>(response);
This works great together with the class getting/setting the properties.
However, what I would like to know is whether there's a good way for a user to update the .JSON file through a textbox UI?
As in:
[textbox - update username] [update button] -> username sent to server -> .JSON file updated -> [textblock - showing updated username in UI].
I'm not looking for exact code solutions, I'm rather looking for good solutions on this, and/or if this is a terrible idea of an easy database(?).
Upvotes: 0
Views: 969
Reputation: 4641
Ok. Now I get it :)
So you want to have a DB. Then read this. 3 methods
Your way. You want to use JSON files. Ok it will work but it's a bad way imo. if you'll have 1 MB file (it's not so big) than every time you'll have to read it, deserialize, update data, serialize and write it again. It isn't a good way.
SQLite. If you want a local database use SQLite. I'm in phase of testing it and it looks good. A disadvantage is poor orm. You need to manage few things by yourself but it work nice. This is a local database so it's not a bad way to go
Azure DB. Main disadvantage is that you app is depended on internet connection and you need to create an API that will provide connection with the DB cause Windows Store Apps can't connect to them by themself. You need also consider creating cache engine cause asking for thata every time is pointless. you can get data and cache them for some views. that way app will work faster
// EDIT
in your updated case you have 2 solutions
In all of this cases you need a db in web and some api to connect with it
Upvotes: 1