how to read and edit json file from internet - flutter

I want to use a JSON file as temp data saving and edit it.
this is how I get data from local, I want to get file from internet and edit it.
var mydata = json.decode(await rootBundle.loadString('/assets/testjson.json'));
thanks in advance.

Related

capacitor unable write blob to file and read it back

I'm trying to write a blob from fetch to a file using capacitor Filesystem.writeFile
when I write the file this is the data I write:
...etc (you get the point full png file as a blob)
but when I read the data this is ALL the data returned
{data: "ZumJPw=="}
Any idea what's going on? How do I fix it?

How to load a template text file in SAPUI5?

I have a template fragment file, which is an xml file in fact.
I want to load it in my controller, do some modification on that, and then use it to render some part of the view.
I only need to read this xml file as text file and put its content in a string.
I cannot find any object for doing this in SAPUI5 api.
Please note the file is placed in my view folder in server side.
I need some kind of promise that read the file and after reading the file run a successor function.
Thanks in advance
There can be multiple ways to to this.
1.Either you can load your XML in an XML Model "sap.ui.model.xml.XMLModel()"
var oModelX = new sap.ui.model.xml.XMLModel();
oModelX.attachRequestCompleted(function(){
var xmlStr = oModelX.getXML();
console.log(xmlStr); // Do what ever you want with your xml string
});
oModelX.loadData("../view/st.fragment.xml");
2.You can also read the content of that XML file using AJAX and do your parsing in AJAX response.

Uploading file to storage without extension

I am trying to create an app where users can upload files to the "wall". The idea is not important. Each file is added both to storage and to database as [fileName : url) under user's profile. Because of limitations regarding strings in database, I keep filenames without extensions (can't use dot symbol). Uploading works fine but I have a problem with deletion. Based on the file user picks to delete in app I get the filename(without extension). My delete function should delete the file from storage but it cannot locate file because of missing extension.
I use this function to upload the data:
let uploadTask = ref.putData(contents as Data, metadata: myMetadata, completion: { (metadata, error) in ...}
and the file itself:
let contents = try Data(contentsOf: url.standardizedFileURL)
Is it possible to upload "contents" without the extension? Or maybe is there another approach I'm missing?
Thanks for tips.
It's not a really good idea to store the names of random things (including files) as keys in Realtime Database. You could make this easier on yourself by pushing an object at a location in the database for each file uploaded. The pushed object could contain the name and location of the file in Storage, along with any other metadata about that file, and you won't have to mangle that data as long as it's stored in values rather than keys.

Store JSON Data (get from .txt file) in Database

I am new at iPhone Development.
I know how to store JSON data in database. But in my case I have .txt file which contain data of JSON. This .txt file i get by send request on Server and i got it as .zip file and after i did it as unzip file so after i get it as .txt file with JSON data. I get this data from .txt file but i dont know how to store it in database.I want to stor this data in DATABASE. How cant i do anybody as idea ???
Data of .txt file of JSON (Display in Console)
"Ok","last_response_date":"2013-02-05 00:04:14","region_master":[{"id":"1","region_name":"Auckland and Kermadec","border_coordinate_file":"","created_date":"2013-02-01 05:22:42","updated_date":"0000-00-00 00:00:00"},{"id":"2","region_name":"Central","border_coordinate_file":"","created_date":"2013-02-01 05:22:42","updated_date":"0000-00-00 00:00:00"},{"id":"3","region_name":"Challenger","border_coordinate_file":"","created_date":"2013-02-01 05:22:57","updated_date":"0000-00-00 00:00:00"},{"id":"4","region_name":"Fiordland","border_coordinate_file":"","created_date":"2013-02-01 05:22:57","updated_date":"0000-00-00 00:00:00"},{"id":"5","region_name":"South East","border_coordinate_file":"","created_date":"2013-02-01 05:23:15","updated_date":"0000-00-00 00:00:00"},{"id":"6","region_name":"Southland","border_coordinate_file":"","created_date":"2013-02-01 05:23:15","updated_date":"0000-00-00 00:00:00"}],
"region_kml_files":
[{"id":"4","region_id":"2","kml_files":"Sample.kml","created_date":"2013-01-25 09:04:58","updated_date":"0000-00-00 00:00:00"}]
EDIT :
I already got data from .txt file
please help me..
Thanks :)
I don't know where you are having trouble, but it seems like you haven't gotten a JSON object from your string yet, so I will let you know how to do that. If you need to know how to create and store data in a database, then you need to make a new question and say that you got JSON data but are having trouble storing it into a database (at least make an effort to try to do it though).
You can use NSJSONSerialization to get an object out of your string (the NSData version of your string, at least). It will look like this:
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:yourData options:kNilOptions error:nil];
If it doesn't work then your JSON is not valid. Validate it at http://www.jsonlint.com
You can use:
NSString *jsonString = [NSString stringWithContentsOfFile:yourFilePath encoding:UTF8StringEncoding error:nil];
Here:
yourFilePath is a NSString which contains the exact path to the .txt file.
You get the file content in jsonString variable, you need to save that string to database.
Refer NSString class for more

CrystalReportSource binding

Hello I have a crystalReportViewer and CrystalReportSource on a web form.
I need to be able to bind the reportSource at run time to different report files.
I have the file data stored in a blob in a DB.
The mechanism I am using now is to save the blob to a file and then
this.CrystalReportSource1.Report.FileName = myFileName;
The issue is that I want to avoid saving the file on disk and somehow bind the report directly to a file stream.
Is that possible?
Thanks
In C#, I believe that you should be able to use something like the following, but I haven't tested it out on my system.
ReportDocument rpt = new ReportDocument();
rpt.Load(filestream); //filestream is your filestream object
Give it a try and let me know if you have issues.