简体   繁体   中英

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!

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.

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. Fe 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.

I found pyjq library very magical, you can feed it a template and json file and it will map it out for you.

https://pypi.org/project/pyjq/

The only thing that is annoying about it was the requirements I have to install for it, it worked perfect on my local machine, but it failed when I tried to build it failed to build dependencies for lambda an aws.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM