You didn’t give full specifics of what is in the file, however I think it may be easier to just use a text editor that has FIND & REPLACE functionality to prep the file for import as JSON.
If the file is formated like so:
“1. Why is the sky blue?”
“2. Why is grass green?”
“3. Why is water green or blue?”
You can easily make this into a file that can be JSON decoded.
If you add [at the beginning of the file,] and the end of the file and put a , between each question, it can be json decoded into a table. I would just insert the two brackets manually and then do a FIND & REPLACE for the carriage return, replace it with a carriage return with a , in front of it. Then just do something like the following in corona to put it in a table. To me this seems easier than coding something as most text editors can do the brunt of the work.
json = require("json")
local text = {}
local path = system.pathForFile( "questions.txt", system.ResourceDirectory )
local fh = io.open( path, "r" )
local data = fh:read( "\*a" )
text = json.decode(data)
print (text[1]) -- prints: 1. Why is the sky blue?
print (text[2]) -- prints: 2. Why is grass green?
print (text[3]) -- prints: 3. Why is water green or blue?
From your description though I am not 100% sure how the file is formated. As other’s mentioned there could be answers in the file as well. Perhaps give as an example of what is really in the file? [import]uid: 56820 topic_id: 33696 reply_id: 134082[/import]