3 ms·
Other dynamically typed languages have already been pointed out, but one that might surprise you is C#. For starters, because it supports [] overloading, you ca
by int_19h 9y ago
Other dynamically typed languages have already been pointed out, but one that might surprise you is C#. For starters, because it supports [] overloading, you can do:
foo["bar"]["baz"]
unlike Java's .get(). But more interestingly, it has opt-in dynamic typing, and the most popular JSON library actually makes use of that. Thus, you can do something like:
dynamic obj = JObject.Parse(json);
int x = obj[0].foo["bar"].baz;
With [] and dot notation both accessing by key, the only difference being quoting.