Open kskyten opened 3 years ago
Related to JuliaData/StructTypes.jl#7
AcuteML is like the JSX of Julia. This library aims to make it easy for developers to build their HTML or XML applications with the least amount of boilerplate code. This has several benefits:
@aml
defined types work just like normal Julia types. (e.g. they can be used for dispatching, they can have custom constructors, etc).# Here you can serialize any HTML that follows this structure. Serialization here means both parsing and creating.
@aml mutable struct Body "~"
h1, "~"
p::Vector{String}, "~"
end
@aml mutable struct Page doc"html"
body::Body, "~"
end
See MusicXML.jl for an example of a library that uses AcuteML: https://github.com/JuliaMusic/MusicXML.jl
If you plan to inject custom code to your AcuteML components there are multiple ways you can do this: https://aminya.github.io/AcuteML.jl/dev/extraConstructors/ https://aminya.github.io/AcuteML.jl/dev/customValueTypes/ https://aminya.github.io/AcuteML.jl/dev/customConstructors/
You can also directly use the AcuteML's backend if you wish (although not necessary at all).
I wrote VarStructs which is similar to AcuteML, but is for any type of data. You can easily define your requirements for data using VarStructs, and everything will be handled for you.
GitHubVariable Julia Structs with dispatching. Contribute to aminya/VarStructs.jl development by creating an account on GitHub.
I don't necessarily see how what I'm thinking of is mutually exclusive. Here is an example to clarify this. Say I have a struct
struct Foo
x::String
y::Int
and I want to serialize it in XML, JSON and possible some other serialization format. If each of the serialization libraries defines their custom APIs with macros, it is difficult to combine them and they have to be added as dependencies.
I'm asking whether it is possible to use a common API for defining the mapping to various serialization formats like Rust's Serde does. As far as I know, StructTypes.jl comes the closest to this kind of API. If it doesn't suit AcuteML, it would be useful to know what is missing so a better API can be built.
Nice package! I really like the way JSON3.jl handles mapping structs to JSON and back. It does this by annotating structs with traits from StructTypes.jl. I wonder if a similar approach could be used with AcuteML. This way you could easily serialize your struct in either JSON or XML. I'm not sure how well XML maps to the existing StructTypes traits, but there is probably some overlap.