Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map/MustMap/Array/MustArray return *Json instead of interface{} #25

Closed
elgs opened this issue Feb 4, 2014 · 5 comments
Closed

Map/MustMap/Array/MustArray return *Json instead of interface{} #25

elgs opened this issue Feb 4, 2014 · 5 comments
Labels

Comments

@elgs
Copy link

elgs commented Feb 4, 2014

I think life will be a lot easier if Map/MustMap/Array/MustArray would return *Json instead of interface{}. No type assertion or casting would not be needed.
Currently, it's like this:

func (j *Json) Map() (map[string]interface{}, error)
func (j *Json) MustMap(args ...map[string]interface{}) map[string]interface{}
func (j *Json) Array() ([]interface{}, error)
func (j *Json) MustArray(args ...[]interface{}) []interface{}

What I'm hoping is:

func (j *Json) Map() (map[string]*Json, error)
func (j *Json) MustMap(args ...map[string]interface{}) map[string]*Json
func (j *Json) Array() ([]*Json, error)
func (j *Json) MustArray(args ...[]interface{}) []*Json

Best regards,
Elgs

@mreiferson
Copy link
Contributor

@elgs there are a few things I would change if given the chance (see #15 for example)

I'm not sure the best way to proceed, though:

  1. plow ahead and clean up the API and encourage users to vendor or otherwise pin dependencies
  2. add a v2 directory to the root of the repo with the new API so users could transition
  3. add a new top-level type with the new API for transition
  4. a new repo

They all have their tradeoffs...

@fd
Copy link

fd commented Mar 13, 2014

maybe you should give http://gopkg.in a try

@mreiferson
Copy link
Contributor

the bitly of go package management!

@cgt
Copy link

cgt commented Mar 13, 2014

I would be wary of using services like gopkg.in. Who runs it? How do we know it won't suddenly disappear?

@mreiferson
Copy link
Contributor

where have I heard these arguments before? 😄

In all seriousness it is a good suggestion and it does provide some nice benefits, but I think one of the options I listed above, perhaps (2) or (3), makes the most sense to me.

@elgs elgs closed this as completed Mar 13, 2014
jacoduplessis added a commit to jacoduplessis/simplejson that referenced this issue May 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants