Re: Json key names encoding

2018-01-29 Thread frogEye
Thanks @dom96

Re: Json key names encoding

2018-01-25 Thread 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

Re: Json key names encoding

2018-01-25 Thread frogEye
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

Re: Json key names encoding

2018-01-25 Thread yglukhov
@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.

Re: Json key names encoding

2018-01-25 Thread frogEye
Thanks, dom96 . But still, the ease with which we can unmarshal and marshal json into a data structure in Go-lang is uncomparable.

Re: Json key names encoding

2018-01-24 Thread dom96
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)

Re: Json key names encoding

2018-01-24 Thread cdome
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/

Json key names encoding

2018-01-24 Thread frogEye
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