Pretty JSON export (#9165)

reviewable/pr9182/r1
Utsob Roy 2 years ago committed by GitHub
parent aa4cc6da56
commit 6918d62bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,6 @@
local json = require("json")
local Device = require("device")
local rapidjson = require("rapidjson")
-- json exporter
local JsonExporter = require("base"):new {
name = "json",
@ -41,7 +42,7 @@ function JsonExporter:export(t)
end
local file = io.open(path, "w")
if not file then return false end
file:write(json.encode(exportable))
file:write(rapidjson.encode(exportable, {pretty = true}))
file:write("\n")
file:close()
return true
@ -51,7 +52,7 @@ function JsonExporter:share(t)
local content = format(t)
content.created_on = self.timestamp or os.time()
content.version = self:getVersion()
Device:doShareText(content)
Device:doShareText(rapidjson.encode(content, {pretty = true}))
end
return JsonExporter

Loading…
Cancel
Save