Hello there,
I am working in a project to work with train schedules.
Sadly, the data is given to me as a series of JSON objects which need to be read in line by line.
Is there a way of batch processing JSON, or do I have to submit line by line?
Shaun
Hi Shaun,
Sadly, the data is given to me as a series of JSON objects which need to be read in line by line.
No problem, try this:
for $line in file:read-text-lines('input.json') return json:parse($line)
If you want to store all objects in a database, you can combine the query with db:add:
for $line at $pos in file:read-text-lines('json.json') return db:add('db', json:parse($line), $pos || '.xml')
Our Wiki will give you some more hints [1,2,3].
Hope this helps, Christian
[1] http://docs.basex.org/wiki/File_Module [2] http://docs.basex.org/wiki/JSON_Module [3] http://docs.basex.org/wiki/Database_Module
Spot on! Thank you very much xx On 9 Apr 2014 11:19, "Shaun Flynn" scfy12@googlemail.com wrote:
Hello there,
I am working in a project to work with train schedules.
Sadly, the data is given to me as a series of JSON objects which need to be read in line by line.
Is there a way of batch processing JSON, or do I have to submit line by line?
Shaun
basex-talk@mailman.uni-konstanz.de