Skip to content

Basic JSON normalization/flattening #4007

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

Merged
merged 2 commits into from
Oct 3, 2013
Merged

Conversation

wesm
Copy link
Member

@wesm wesm commented Jun 23, 2013

closes #1067.

This isn't a fast function but has quite a bit of functionality. Take a look at the unit tests. Comments on the API welcome and this could use a few iterations. Various ad hoc things like concatenating "key paths" to metadata

@wesm
Copy link
Member Author

wesm commented Jul 2, 2013

@nehalecky can i get some feedback?

@nehalecky
Copy link
Contributor

@wesm, hey! Yes, I will roll this out to a direct use case I have and let you know. I was hoping to do so today, so I'll get back soon. ty.

@nehalecky
Copy link
Contributor

Really busy yesterday, I am going to try and get to this today. :)

@jreback
Copy link
Contributor

jreback commented Jul 12, 2013

@nehalecky did you get a chance to try out?

we adding this to 0.12?

@nehalecky
Copy link
Contributor

Hey @jreback. I am finishing one last deadline (due today). My very next project will benefit much from this functionality, so I will be testing it out. I have a deadline for this early next week, and will certainly have reviewed this by then. If that works, great and either way I will let you know my thoughts. :) THANKS!

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

maybe push to 0.13? @wesm?

@wesm
Copy link
Member Author

wesm commented Jul 14, 2013

yes let's push to 0.13 so it can see some work

@ghost
Copy link

ghost commented Jul 22, 2013

Warning: cute.

def jqj(data,rule):
     from sh import jq
     from sh import ErrorReturnCode
     import json   
     jq = jq.bake('-M')
     try:
         return json.loads(jq(rule,_in=json.dumps(data)).stdout)
     except ErrorReturnCode as e:
         raise RuntimeError("Jq exited with an error\n%s" % str(e))
     data = dict(dwarves={'names':['dancer','prancer','grinch']},tale='rambo II')
     rule = '[{name: .dwarves.names[],tale}]'
     jqj(data,rule)

[{u'name': u'dancer', u'tale': u'rambo II'},
 {u'name': u'prancer', u'tale': u'rambo II'},
 {u'name': u'grinch', u'tale': u'rambo II'}]

jq

@cpcloud
Copy link
Member

cpcloud commented Jul 22, 2013

That's pretty nifty

@jreback
Copy link
Contributor

jreback commented Sep 22, 2013

@nehalecky @cpcloud @wesm try to merge to 0.13?

@jreback
Copy link
Contributor

jreback commented Sep 29, 2013

@nehalecky have a look?

@jreback
Copy link
Contributor

jreback commented Oct 1, 2013

@wesm, merge this?

@wesm
Copy link
Member Author

wesm commented Oct 3, 2013

Sure, it's good to go by me.

@jreback
Copy link
Contributor

jreback commented Oct 3, 2013

ok..let me rebase....and can do

jreback added a commit that referenced this pull request Oct 3, 2013
Basic JSON normalization/flattening
@jreback jreback merged commit a2c8f44 into master Oct 3, 2013
@nehalecky
Copy link
Contributor

Sorry all, life + work is all really busy. In startup's requirements change quickly! Regarding the PR, glad to see it's been merged and included in 0.13. I'm eager to work with it, and when I do, I will provide feedback.

Thank for all your efforts!

@jreback
Copy link
Contributor

jreback commented Oct 3, 2013

@nehalecky gr8...try it out....it may not be super fast....(optimization PR's always welcome)...b.ut should be good on moderately sized sets

@ghost ghost deleted the PR_json-normalize-proto branch November 18, 2013 15:52
@cpcloud
Copy link
Member

cpcloud commented Feb 1, 2014

@ghost
Copy link

ghost commented Feb 1, 2014

I've looked at this again recently for other reasons and found plenty of existing,
dedicated languages for doing this. Basically, XML has XSLT for doing transformations
and lots of people came up with the idea of doing the same for JSON.

If you're interested google: jaql, jsonpath, jsoniq or jsont.

Appreciate your care for attribution.

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

Successfully merging this pull request may close these issues.

Handling of nested JSON records
4 participants