Need advice, typing strings, runtime types

Hej all !

Long time I haven’t post anything here, I’m sure you missed me guys ! :rofl:

I wonder if anyone know a library or something that unify types especially from strings like from a html textfield or textarea.
It’s difficult to explain what I want to achieve, I’ve wrote a simple piece of code maybe if someone has time and bravery to take a look at, I’m sure it will be more clear : Try Haxe !

So especially looking at the String part, what I wanted is people that are not coders, can write things in textfields/textareas in a human-reading style and I’ll get the right type from that, especially the arrays and “objects” (more like hashmaps/pairs key/value…)

Maybe there already exist libs that do this kind of stuff ? Or if not, is what I’ve written a good way to go ? And if it is, what do you think about L64, L65, L71 and L72 ?

Well, many thanks for reading me and more thanks if you give any answer/advice ! :stuck_out_tongue_closed_eyes:

(it’s not April Fool … :sweat_smile:)

Do you have a complete example of user input that you expect? The current example you provide is just showing a bunch of individual tests. Are you obtaining the input as one large string, Json, xml, etc?

Thanks for your answer !

I don’t have any example, but yes, user will enter sometimes a random text, sometimes an integer/float, sometimes a bool (I think 0/1 is more human style than “true/false”, that’s why I “parse” 0/1 as true/false…). It will mainly come from a html textfield or textarea.
Sometimes an array will be asked also, that why I’ve done that a string with commas is “parsed” as an array (no “[” / “]” needed), and I thought also about some “pairs” (key/value) so no “{” / “}” needed also.
All that fits quite well with json format that’s why I also use Json parser for arrays/objects (pairs) just giving the possibility to omit the [ ] and { } which is more human style IMHO…