Big Chungus
10/14/2021, 10:53 AM{
"boolean": true,
"number": 1,
"string": "str",
"null": null,
"array": [
1,
"str",
null,
{},
[
1,
"2",
null,
3
]
],
"object": {
"boolean": true,
"number": 1,
"string": "str",
"null": null,
"array": [
1,
"str",
null
]
}
}
Robert Jaros
10/14/2021, 11:05 AMBig Chungus
10/14/2021, 11:06 AMarekolek
10/14/2021, 12:17 PMBig Chungus
10/14/2021, 12:26 PM$
that just feels unnatural. I found the DSL much more comfortable to work with as it closer matches json structure and allows direct references to variables (no $
required)Javier
10/14/2021, 2:07 PMbuild...
functionsBig Chungus
10/14/2021, 2:09 PMJavier
10/14/2021, 2:10 PMby
can't be replaced by operator fun equals
?Big Chungus
10/14/2021, 2:20 PMJavier
10/14/2021, 2:35 PMTobias Berger
10/14/2021, 2:41 PMby
infix function, you could implement a rangeTo
operator function, so
{
"number" by 1
}
becomes
{
"number"..1
}
which looks a bit like the :
just fell over 😄equals
already exists on every type and extension functions can't override member functions. Also, it would result in the usage of ==
, not =
and wouldn't work properly with null values (if I remember the behaviour correctly)jimn
10/14/2021, 3:04 PMJavier
10/14/2021, 3:06 PM=
can be used or only ==
Tobias Berger
10/14/2021, 3:08 PM=
assigns a value, the equality check is always ==
Javier
10/14/2021, 3:09 PMto
to keep consistence with languages features if =
cant be usedjimn
10/14/2021, 3:39 PMinfix operator fun String.rem(value: Any?) = this `⁚` value //two escaped dots if inlined
@JSSetterDsl
/**
* set primitive
*/
infix fun String.`⁚`(t: Any?) { map[this] = t }
...
val `{}` by lazy { JSObj().apply(fun JSObj.() = Unit) }
some options.
alternatives to backticks would be great in kotlin.Big Chungus
10/14/2021, 3:53 PMJavier
10/14/2021, 4:01 PMBig Chungus
10/14/2021, 5:05 PM==
and backticks.Javier
10/14/2021, 6:44 PMModules
kon - wrapper module
Big Chungus
10/14/2021, 6:45 PMOliver.O
10/14/2021, 9:01 PMby
, the second adds stuff with %
, and so on. I'd stick with the usual to
as this aligns with Kotlin map notation, and avoid synonymous operators.Big Chungus
10/14/2021, 10:38 PMJavier
10/14/2021, 10:47 PMto
is enough and it is used to build maps, I like += too.Big Chungus
10/14/2021, 11:49 PMJavier
10/15/2021, 2:01 AMephemient
10/15/2021, 9:20 AMBig Chungus
10/15/2021, 9:22 AMJavier
10/15/2021, 9:24 AMbuild...
JsonElement
with your syntaxBig Chungus
10/15/2021, 9:25 AMephemient
10/15/2021, 9:27 AMOliver.O
10/15/2021, 11:09 AMkotlinx.serialization
API seems to ease onboarding (with IDE support, you'd just type put
and use completion). I am undecided whether its verbosity might increase reading/scanning time when compared to a map-like to
notation. Probably not much, if at all. In the end, I tend to think it is like using different indentation styles: While I do prefer certain styles over others, what really matters most is consistency.Big Chungus
10/15/2021, 1:33 PMKON
and JsonObject
Matteo Mirk
10/15/2021, 3:10 PMephemient
10/15/2021, 8:30 PM"array"[1]
in KObject may be an issue… what if you changed the DSL to
kobj {
"scalar" to 1
"object".to { ... }
"array".to[ ... ]
}
instead? seems more consistent to meBig Chungus
10/15/2021, 9:37 PMephemient
10/15/2021, 10:36 PM