view src/luan/modules/Parsers.luan @ 1735:4b56eff90040 default tip

add hosting.html
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 02 Oct 2022 17:32:00 -0600
parents 36c28be6d432
children
line wrap: on
line source

require "java"
local BBCode = require "java:goodjava.bbcode.BBCode"
local BBCodeLuan = require "java:luan.modules.parsers.BBCodeLuan"
local Csv = require "java:luan.modules.parsers.Csv"
local Theme = require "java:luan.modules.parsers.Theme"
local Xml = require "java:luan.modules.parsers.Xml"
local XmlElement = require "java:goodjava.xml.XmlElement"
local BasicLuan = require "java:luan.modules.BasicLuan"


local Parsers = {}

Parsers.bbcode_encode = BBCode.encode
Parsers.bbcode_parse = BBCodeLuan.parse
Parsers.csv_to_list = Csv.toList
Parsers.json_string = BasicLuan.json_string
Parsers.theme_to_luan = Theme.toLuan
Parsers.xml_encode = XmlElement.encode
Parsers.xml_parse = Xml.parse
Parsers.xml_string = Xml.toString

local Luan = require "luan:Luan.luan"
local error = Luan.error
local type = Luan.type or error()
local Table = require "luan:Table.luan"
local java_to_table_deep = Table.java_to_table_deep or error()
local JsonParser = require "java:goodjava.json.JsonParser"

-- converts json string to luan object
function Parsers.json_parse(s)
	local obj = JsonParser.parse(s)
	return type(obj)=="java" and java_to_table_deep(obj) or obj
end

return Parsers