Thanks @dom96
Nim offers similar functionality via the `to` macro, but indeed it doesn't
support fields that begin with a number. I created an issue for this:
[https://github.com/nim-lang/Nim/issues/7139](https://github.com/nim-lang/Nim/issues/7139).
Depending on your JSON you may be able to use a combination
Thanks yglukhov for the reply. It just an observation as I have just started
with nim-lang. So may be I was looking at things which I could do really fast
in go to be in nim. I will take some time to get used to nim
@frogEye. That is true because nim ideology differs a lot from go. Instead of
providing some high level feature the nim compiler will tend to provide you
with rich metaprogramming capabilities, and with those you can implement high
level features that look and feel like native nim constructs. E.
Thanks, dom96 . But still, the ease with which we can unmarshal and marshal
json into a data structure in Go-lang is uncomparable.
You should do this:
[https://nim-lang.org/docs/json.html#dynamically-retrieving-fields-from-json](https://nim-lang.org/docs/json.html#dynamically-retrieving-fields-from-json)
Latest Nim dev has custom pragmas that can be useful in this case.
Details at the bottom of
[https://github.com/nim-lang/Nim/blob/devel/doc/manual/pragmas.txt](https://github.com/nim-lang/Nim/blob/devel/doc/manual/pragmas.txt)
Examples:
[https://github.com/nim-lang/Nim/blob/devel/tests/pragmas/
I have looking for a way to encode the json keys, but has not been able to find
anything on that.
For example Go lets us do this
type Response2 struct {
Page int json:"page" Fruits []string json:"fruits"
}
I want to unmarshal a json object but not able to encode the json keys. As my
key n