Skip to content

CoburnJoe/bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bus - Python Json Aggregator

Pre-Alpha project

Takes json payloads and combines them by nesting one in the payload of another using a shared key.

Installation

Install with Pip:

pip install bus

Usage

from bussing.busses import Bus
Bus().group(parent='PARENT JSON', child='CHILD JSON', keys=[("id", "shapes")])

Keys needs to be a list of tuples. The first element is the key ID to match results with, and the second is the new name to list items as under the parent.

Examples

Given:

[
   {
      "id":"Apples",
      "colours":[
         "Red",
         "Green"
      ]
   },
   {
      "id":"Bananas",
      "colours":[
         "Yellow"
      ]
   },
   {
      "id":"Mangos",
      "colours":[
         "Orange",
         "Green"
      ]
   }
]

And:

[
   {
      "id":"Apples",
      "round":true
   },
   {
      "id":"Bananas",
      "round":false
   }
]

You can combine these results into one payload:

[
   {
      "id":"Apples",
      "colours":[
         "Red",
         "Green"
      ],
      "shapes":{
         "round":true
      }
   },
   {
      "id":"Bananas",
      "colours":[
         "Yellow"
      ],
      "shapes":{
         "round":false
      }
   },
   {
      "id":"Mangos",
      "colours":[
         "Orange",
         "Green"
      ]
   }
]

Links

About

Seamlessly nest JSON payloads

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages