Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Library - json to json transformations

Does anyone know of a python library to convert JSON to JSON in an XSLT/Velocity template style?

JSON + transformation template = JSON (New)

Thanks!

like image 684
Kurt Maile Avatar asked Oct 18 '16 19:10

Kurt Maile


Video Answer


2 Answers

I have not found the transformer library suitable for my needs and spend couple of days trying to create my own. And then I realized that creating transformation scheme is more difficult than writing native python code that transforms one json-like python object to another.

I understand, that this is not the answer to original question. And I also understand that my approach has certain limitations. F.e. if you need to generate documentation it wouldn't work.

But if you just need to transform json-like objects consider the possibility to just write python code that does it. Chances are that the code would be cleaner and easier to understand than transformation schema description.

I wish considered this approach more seriously couple of days ago.

like image 75
lesnik Avatar answered Nov 13 '22 04:11

lesnik


Sorry if it's old, but you can use this module https://github.com/Onyo/jsonbender Basically it transform a dicc to another Dicc object using a mapping. What you can do is to dump the json into a dicc, transform it to another dicc and then transfrom it back to a json.

like image 25
David Eduardo Cortelezzi Avatar answered Nov 13 '22 06:11

David Eduardo Cortelezzi