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

label support #15

Open
zedoul opened this issue Mar 13, 2017 · 6 comments
Open

label support #15

zedoul opened this issue Mar 13, 2017 · 6 comments

Comments

@zedoul
Copy link

zedoul commented Mar 13, 2017

Hi such a nice package. Any chance you are going to add a "label" support as it is in JSON stat offical example? Adding label attribute, which is the same level as index attribute, would be helpful.

Just to make things clear: here is one example for label attribute (https://json-stat.org/samples/oecd.json)

"area" : {
		"category" : {
			"index" : {
				"AU" : 0,
				"AT" : 1,
                                    ...
                            },
			"label" : {
				"AU" : "Australia",
				"AT" : "Austria",
                                    ...
                            },
 }

And here is the result of rjstat:

"category":{"index":["Australia","Austria",...]}

which has labels data in index attribute, not separated.

I wonder this difference between official one and outcome of rjstat, is something you intended to do or something that needs to be improved. The official site (https://json-stat.org/format/#index) states that the first one is recommended --- "For efficiency reasons (see Arrays vs. Objects), an object that attaches a position to every ID can also be used (this is currently the recommended format)."

If you have no plan to introduce that feature yet, then do you have any idea of how to achieve that? I may implement that feature, but I know not the whole picture of this package so it would be great to know some direction.

Thank you.

@ajschumacher
Copy link
Owner

Hi @zedoul! Do you mean support as is currently described like this in README.md?

# You can also read in using the typically terser IDs rather than labels.
results <- fromJSONstat(readLines(oecd.canada.url), naming="id")

The key part there is the naming="id".

Let me know if that works for you, or whether you mean something else.

(Also, I haven't used rjstat in a while; @hmalmedal may have a better understanding of this.)

@zedoul
Copy link
Author

zedoul commented Mar 13, 2017

Thank you for your response :D

Do you mean support as is currently described like this in README.md?

No.

What I asked was to create label attribute by using toJSONstat function like

AS-IS

> cat(toJSONstat(fromJSONstat(readLines(oecd.canada.url))))
"category":{"index":["2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014"]}

TO-BE

> cat(toJSONstat(fromJSONstat(readLines(oecd.canada.url))))
"category":{"index":["2003":0,"2004":1,...], "label":["2003":"2003", "2004":"2004",...]}

I know this example is bad xD, this is exactly the same as in the official website (https://json-stat.org/format/#label). But, for some case, I need label attribute.

The point is, I hope to add label attribute by using toJSONstat function, and it is not related with fromJSONstat.

@ajschumacher
Copy link
Owner

Ah! Okay, I think I see. Seems like a good idea!

@zedoul zedoul mentioned this issue Sep 10, 2018
@ajschumacher
Copy link
Owner

ajschumacher commented Sep 10, 2018

@zedoul created a package that (I guess?) implements this idea and "implement[s a] tidyverse-like way of describing JSON-stat description not the rjstat way". I haven't checked it out, but maybe it's great!

https://github.com/zedoul/jsonstat

@badosa
Copy link

badosa commented Sep 11, 2018

I don't see the point of having two similar (but different) JSON-stat packages for R. Can @zedoul's new functionality be included in rjstat?

@ajschumacher
Copy link
Owner

I think it could be, but I'm not totally sure what the changes are; I'd love to see a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants