FAQ
Hi,

I am announcing data conversion library to convert interface{} to string,
int, []string, map[string]string, etc
Nothing special but I have not found anything simple that I could use to
convert interface{} after unmarshaling JSON in interface{} or
map[string]interface{}
I found it useful to process JSON in webservices.

I hope someone will find it helpful too.

https://github.com/CossackPyra/pyraconv

https://godoc.org/github.com/CossackPyra/pyraconv

Best,
Pyra

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Egon at Apr 8, 2015 at 7:39 am
    Why not use simplejson
    instead? https://godoc.org/github.com/bitly/go-simplejson
    Or something similar.
    On Tuesday, 7 April 2015 23:42:01 UTC+3, pyra...@gmail.com wrote:

    Hi,

    I am announcing data conversion library to convert interface{} to string,
    int, []string, map[string]string, etc
    Nothing special but I have not found anything simple that I could use to
    convert interface{} after unmarshaling JSON in interface{} or
    map[string]interface{}
    I found it useful to process JSON in webservices.

    I hope someone will find it helpful too.

    https://github.com/CossackPyra/pyraconv

    https://godoc.org/github.com/CossackPyra/pyraconv

    Best,
    Pyra
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Pyraninja at Apr 8, 2015 at 8:37 am
    1. I have not seen go-simplejson.

    If I knew about go-simplejson then possibly I used go-simplejson.

    But I was looking for a set of functions to convert interface{} in certain
    types after I unmarshaled to map[string]interface{}

    MustString(), MustStringArray() does pretty same thing that my ToString(),
    ToStringArray() does.

    My functions work with interface{} type and are more general. They could be
    used with other serilization formats that are parsed in interface{} like
    json package does.

    My lib is smaller and simpler. If you look ToString method
    https://github.com/CossackPyra/pyraconv/blob/master/util.go#L89

    then you will see it is just switch and nil verification.



    среда, 8 апреля 2015 г., 10:39:47 UTC+3 пользователь Egon написал:
    Why not use simplejson instead?
    https://godoc.org/github.com/bitly/go-simplejson
    Or something similar.
    On Tuesday, 7 April 2015 23:42:01 UTC+3, pyra...@gmail.com wrote:

    Hi,

    I am announcing data conversion library to convert interface{} to string,
    int, []string, map[string]string, etc
    Nothing special but I have not found anything simple that I could use to
    convert interface{} after unmarshaling JSON in interface{} or
    map[string]interface{}
    I found it useful to process JSON in webservices.

    I hope someone will find it helpful too.

    https://github.com/CossackPyra/pyraconv

    https://godoc.org/github.com/CossackPyra/pyraconv

    Best,
    Pyra
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Egon at Apr 8, 2015 at 8:53 am

    On Wednesday, 8 April 2015 11:37:50 UTC+3, pyra...@gmail.com wrote:
    1. I have not seen go-simplejson.

    If I knew about go-simplejson then possibly I used go-simplejson.

    But I was looking for a set of functions to convert interface{} in certain
    types after I unmarshaled to map[string]interface{}

    MustString(), MustStringArray() does pretty same thing that my ToString(),
    ToStringArray() does.

    My functions work with interface{} type and are more general. They could
    be used with other serilization formats that are parsed in interface{} like
    json package does.

    My lib is smaller and simpler. If you look ToString method
    https://github.com/CossackPyra/pyraconv/blob/master/util.go#L89
    <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FCossackPyra%2Fpyraconv%2Fblob%2Fmaster%2Futil.go%23L89&sa=D&sntz=1&usg=AFQjCNH9iUVSm_iV9IYh65oNCSbRyphpCw>
    Actually smaller and simpler would be to use a specific conversion code
    when you need it instead of trying to find a package that does it for you.
    Or, just use fmt.Sprintf("%s", v)... which pretty much works all the time.

    Just a suggestion regarding Go packages - try to avoid writing very general
    packages, because
    1. It takes time to develop them properly, compared to just using your own
    internal function
    2. General packages are harder to use than specific ones
    3. Specific packages provide much more clarity to the code
    4. It's harder to find general packages

    i.e. GapBuffer is probably not a good candidate for a package, but
    EditorBuffer is.

    Basically, only if you really end up using significant amount of same code
    in multiple places, then it's worth making into a separate package.

    + Egon

    then you will see it is just switch and nil verification.


    среда, 8 апреля 2015 г., 10:39:47 UTC+3 пользователь Egon написал:
    Why not use simplejson instead?
    https://godoc.org/github.com/bitly/go-simplejson
    Or something similar.
    On Tuesday, 7 April 2015 23:42:01 UTC+3, pyra...@gmail.com wrote:

    Hi,

    I am announcing data conversion library to convert interface{} to
    string, int, []string, map[string]string, etc
    Nothing special but I have not found anything simple that I could use to
    convert interface{} after unmarshaling JSON in interface{} or
    map[string]interface{}
    I found it useful to process JSON in webservices.

    I hope someone will find it helpful too.

    https://github.com/CossackPyra/pyraconv

    https://godoc.org/github.com/CossackPyra/pyraconv

    Best,
    Pyra
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Pyraninja at Apr 8, 2015 at 9:06 am
    May be it is reason why it is so unique. Anyway I hope I will see similar
    lib to compare.
    I have not found many data conversion libraries in go.



    Just a suggestion regarding Go packages - try to avoid writing very
    general packages, because
    1. It takes time to develop them properly, compared to just using your own
    internal function
    2. General packages are harder to use than specific ones
    3. Specific packages provide much more clarity to the code
    4. It's harder to find general packages

    i.e. GapBuffer is probably not a good candidate for a package, but
    EditorBuffer is.

    Basically, only if you really end up using significant amount of same code
    in multiple places, then it's worth making into a separate package.

    + Egon
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Egon at Apr 8, 2015 at 9:15 am

    On Wednesday, 8 April 2015 12:06:35 UTC+3, pyra...@gmail.com wrote:
    May be it is reason why it is so unique. Anyway I hope I will see similar
    lib to compare.
    I have not found many data conversion libraries in go.
    After a quick search I found: https://godoc.org/github.com/issue9/conv
    But, after looking what it is imported by, it mostly can be just removed.
    I.e. only few funcs are actually being used (in public repos) and those
    uses can be quite simply replaced with a small utility func.


    Just a suggestion regarding Go packages - try to avoid writing very
    general packages, because
    1. It takes time to develop them properly, compared to just using your
    own internal function
    2. General packages are harder to use than specific ones
    3. Specific packages provide much more clarity to the code
    4. It's harder to find general packages

    i.e. GapBuffer is probably not a good candidate for a package, but
    EditorBuffer is.

    Basically, only if you really end up using significant amount of same
    code in multiple places, then it's worth making into a separate package.

    + Egon
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Pyraninja at Apr 8, 2015 at 11:00 am
    Nice lib. MustString and MustInt64 are similar to mine and lib supports
    more types.

    I have functions to work with Array and Map and they dont

    e.g. ToStringMap creates map[string]string from map[string]interface{} by
    converting it fields using ToString() function.
    Same for []string and ToStringArray will convert "string" in ["string"]

    json.Unmarshal does not return map[string]string even when all fields are
    strings.




    среда, 8 апреля 2015 г., 12:15:47 UTC+3 пользователь Egon написал:
    On Wednesday, 8 April 2015 12:06:35 UTC+3, pyra...@gmail.com wrote:

    May be it is reason why it is so unique. Anyway I hope I will see similar
    lib to compare.
    I have not found many data conversion libraries in go.
    After a quick search I found: https://godoc.org/github.com/issue9/conv
    But, after looking what it is imported by, it mostly can be just removed.
    I.e. only few funcs are actually being used (in public repos) and those
    uses can be quite simply replaced with a small utility func.


    Just a suggestion regarding Go packages - try to avoid writing very
    general packages, because
    1. It takes time to develop them properly, compared to just using your
    own internal function
    2. General packages are harder to use than specific ones
    3. Specific packages provide much more clarity to the code
    4. It's harder to find general packages

    i.e. GapBuffer is probably not a good candidate for a package, but
    EditorBuffer is.

    Basically, only if you really end up using significant amount of same
    code in multiple places, then it's worth making into a separate package.

    + Egon
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 7, '15 at 8:41p
activeApr 8, '15 at 11:00a
posts7
users2
websitegolang.org

2 users in discussion

Pyraninja: 4 posts Egon: 3 posts

People

Translate

site design / logo © 2022 Grokbase