Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New internal type: Dynamic, Compiler getDynamic: Any #319

Open
gavr123456789 opened this issue Dec 2, 2024 · 1 comment
Open

New internal type: Dynamic, Compiler getDynamic: Any #319

gavr123456789 opened this issue Dec 2, 2024 · 1 comment

Comments

@gavr123456789
Copy link
Owner

New type dynamic, that works the same as this JSON generator Obj implementation https://github.com/gavr123456789/bazar/blob/main/Examples/JSON/main.niva#L1

union JsonObj =
| JsonArray arr: MutableList::JsonObj
| JsonNumber num: Double
| JsonString str: String
| JsonFields fld: MutableMap(String, JsonObj)
type Person name: String age: Int

person = Person name: "Alice" age: 32
x = Compiler getDynamic: person
// x is kinda JsonObj now 
JsonFields: #{ "name" (JsonString str: "Alice") 
                         "age" (JsonNumber num: 32)}

So now it can be easily transformed to json or XML or mapped to data base liki in exposed, but without inheritance.

Such Dynamit to Json is just a usual libraries, same as https://github.com/gavr123456789/bazar/blob/main/Examples/JSON/main.niva#L30

@gavr123456789
Copy link
Owner Author

this is kinda EDN from Clojure https://github.com/edn-format/edn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant