Live data from Hacker News

Show HN: Jason – A new JSON Library for Go

github.com

21–30 of 55 posts

Re: Show HN: Jason – A new JSON Library for Go

#22
post #5

I would stray away from making the library name too similar in phonetic sound to the data it's meant to process. There was already enough confusion in an office I worked at with a non-developer whose name was "Jason"

I pronounce JSON as "jay-sawn" to avoid the confusion with the name. I've heard "jiss-on" and various other mutations used as well.

American? The North American accent pronounces "Python" similarly, as "py-THAWN" instead of "PIE-thn".

Re: Show HN: Jason – A new JSON Library for Go

#23

For anyone wondering why this is necessary, as some others in this thread have mentioned, the standard go way to deserialize json is to pass a pointer to a struct, and the system will "fill" it with the json. There is no easy way to sort of "parse" json piece by piece, which is what this library provides

> There is no easy way to sort of "parse" json piece by piece You mean like this? http://play.golang.org/p/mMh7HGuTbe

You're still parsing the entire JSON document at once. I believe what OP meant was getting a nested property without all the overhead of writing structs or parsing the entire JSON object into an interface{}, []string, map or whatever else is appropriate.

Re: Show HN: Jason – A new JSON Library for Go

#25

For anyone wondering why this is necessary, as some others in this thread have mentioned, the standard go way to deserialize json is to pass a pointer to a struct, and the system will "fill" it with the json. There is no easy way to sort of "parse" json piece by piece, which is what this library provides

Passing a pointer to a struct is just one way to use the standard Go package. You can also pass a pointer to an interface{}, []interface{} or map[string]interface{} depending on how much of the structure you know. You can also use these types in struct fields.

[deleted]

Re: Show HN: Jason – A new JSON Library for Go

#26
post #2

[deleted]

Here this nice person created something for themselves and decided to share it with others and this is your reaction. There are a number of ways to express the question "What are the advantages of using this tool over the stdlib?" without coming across as needlessly confrontational. It's unfortunate that so many of these "Show HN" threads turn into this.

I was genuinely curious, hence my question. I did not realize HN had the requirement that all posts be run through some sort of psychic expectation filter that magically tells me the exact mental state of other people and how the post will "come across" to them.

But ok, I will delete the post anyway.

Re: Show HN: Jason – A new JSON Library for Go

#27

I would say the most idiomatic way is having defined structs and using encoding/json. Even when you don't know the json schema in advance you can still parse it into an interface{}. Here's an example: http://play.golang.org/p/jrqBcPuQei

You can parse JSON into an interface, but you end up doing tiresome casts if you structure is just somewhat nested.

Re: Show HN: Jason – A new JSON Library for Go

#28

Earlier quoted context omitted.

> There is no easy way to sort of "parse" json piece by piece You mean like this? http://play.golang.org/p/mMh7HGuTbe

You're still parsing the entire JSON document at once. I believe what OP meant was getting a nested property without all the overhead of writing structs or parsing the entire JSON object into an interface{}, []string, map or whatever else is appropriate.

The jason package implementation decodes the entire JSON object to an interface{} using the standard encoding/json package.

Re: Show HN: Jason – A new JSON Library for Go

#30

I would say the most idiomatic way is having defined structs and using encoding/json. Even when you don't know the json schema in advance you can still parse it into an interface{}. Here's an example: http://play.golang.org/p/jrqBcPuQei

You can parse JSON into an interface, but you end up doing tiresome casts if you structure is just somewhat nested.

...or use very simple lib like this one [1] to access to deep-nested structs using one call.

[1] https://github.com/zazab/zhash

Post reply on HN