Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In the backend of my IOS project, the admin is saving the data into a DB or in an XML file. So whenever he wants, he can simply add an entry.
In the IOS app, I want to retrieve the data.
If I use XML, I can directly parse the XML file, since data are already in XML format (when admin added the value, the XML file got updated).
If I use JSON, I have to connect to the DB, get the result of the query and then encode it into JSON.
So, what do you think would be faster, in terms of the response come into phone.
Is there any other option that I didn't take into account?
I have read all of these similar questions:
JSON and XML comparison [closed],
What's better: Json or XML (PHP) [closed],
JSON or XML: Just Decide (April 2012; by Mark Nottingham)
and many more, but I want to ask something specific for my project.
It depends on lots different things:
amount of data
cpu time needed to generate the data
network bandwith/latency
mobile phone's hardware
...
But because generally mobile network is the bottleneck, probably the less redundant transfer will be the most efficient. And it is json in this case.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am building a social networking website and should i use JSON instead of database for storing users posts and comments? Is it good and secure?
JSON is a format, not a file standard. So you could even think of storing JSON in DB.
So, you will need to answer two questions
is file format better than real DB format (like MySQL like databases)?
is JSON format good for the use I have?
File format
Because you will have to deal with quick access and sometimes complex queries (search engine, statistics, ... ), it's clear that a DB system will be much more efficient than a file system oriented solution. File creations / openings / writings / closings need a lot of time and it will be a pain to create search queries. In PHP you would have to open all your files and put them in memory beforte doing the real job.
Using a Database, you would perhaps be directly be able to ask the system if someone with "%john%" in his name has posted something about "%futurama%" in the title.
So... one point for DB
JSON format stored in DB
One more time, you'd better use rows capacities of the DB system. By that, I mean using a author_id row for example. It would greatly impact the perfs. On the other hand, you would have to think of complex queries dealing with the downsides of the JSON format in your DB engine query.
One more point for not using JSON
But when using JSON?
JSON is great when dealing with APIs. If you need to serve data for an application (i.e. an Angular2 front end that will query your API), JSON is a native format to manage data... but not for storing it... JSON is more often used for stream purposes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have different sources like S3 (json files) and API, and I have to bring all the data to a unique format to store the data in DB.
I tried to parse files and API response on my php back-end but it is too slow.
Is there some best practices or advises how I can do it in a right way?
I'm going to do an Interface with all required methods, and Class' for every source which will implement the Interface.
If I will work with hundreds or thousands files (per hour) Is this approach the best way to do it?
P.S. Currently the project is build on top of Symfony2 framework.
I guess you are forced my traditional RDBMS to convert all sources to specific format.
You may use schema-less systems like MongoDB, Cassandra or even JSON type in MySQL 5.7 to store 3 fields: id, source_type and source_json. This way you create several classes that know how to parse the source_type (ex: S3) and use them accordingly
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I will be getting tens of thousands of XML documents that I'll need to query. The queries need to encompass all the XML files, not just querying individual files. For example, I might need:
Return the <name> value from the XML file whose <publish_date> is the most recent
What technologies or approach can I use for this scenario?
Loop through each XML file and execute an XPath? This would be too expensive and not scalable
Consume the XML and insert it into a database that has been modeled to respect the XML's schema? Then just do regular SQL queries to get the data I need?
Use an XML database?
Would XQuery be an option?
This needs to be part of an PHP/MySQL solution.
Take your XML files and insert them into eXist-db. You can insert these easily from PHP by doing either a HTTP POST or PUT against their REST API (depending on your needs). If you insert them into the same collection you can then from PHP do a HTTP GET or POST sending an XQuery that queries all of the documents from the same collection, for example.:
collection("/db/your-collection-of-documents")//name[parent::element()/publish_date gt "2014-006-14"]
If you can be more specific about your XML, I could update this question with the REST URI that you would need to use, and an appropriate XQuery.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I would like to know how a server, running MySQL, can respond to a iOS device if they had passed info through the URL. I'm a web developer helping a friend link his app with a server and it's database.
The set up:
MySQL on server
PHP
iOS device with app to access server's urls
Technique:
The webpage will extract the $_GET parameters from the URL and query the database with the parameters. How would I pass data (the database query's data) back to the iOS device from this PHP page?
Is JSON a solution? If my .php page encodes a JSON format, will the device be able to pick up the data that is returned from the database?
I don't really know what's happening backstage with apps like flickr api and such that lets iOS devices query a database and get url strings returned to retrieve pictures. Can someone elaborate on this?
The server response can be anything you want. It is common for the response to be data formatted as JSON. It can be XML, plain text, or proprietary binary format. It doesn't matter. The iOS app will get the response. As long as both sides agree on a format it can be made to work.
You can do this in any format you want, but one of the most common ways is JSON:
pass back a json object in php
<?php
echo json_encode($my_array);
?>
using the NSURLConnection class to make the request and the NSJSONSerialization class to convert your JSON response to a dictionary/array.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have inherited a php site that is returning HTML pages. I always thought that the server returns data to the client and the client decides how to show the results.
Even though this is working, is this not a very tight coupling between the server and the client?
I would have thought a much better way to handle this is for the client code, javascript or gwt or what have you to ask for the needed data and the server returning that data only such as JSON object or a similar thing.
Thoughts on this?
It sounds like you could benefit from making an AJAX call (via js) to a php page, then manipulating the data (JSON object, string of comma delimited data, raw HTML, etc.) returned on the client side.
Sorry for the bad previous example, this example is a more sophisticated, modern example of how an ajax call should be made.
It appears that it is not at all uncommon for php scripts to return HTML. It does create tight coupling with the client application. Returning JSON does create a more loosely coupling with the client.