ironSource / parquetjs

fully asynchronous, pure JavaScript implementation of the Parquet file format
MIT License
348 stars 175 forks source link

Tool to print schema of a given json object (for use with parquetjs) #96

Open ipsquare opened 4 years ago

ipsquare commented 4 years ago

I am curious if there is a tool or utility which can print schema of a given json object. Please advice.

eg.:

const jsonObj = {name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true};
function printSchema(obj) {
    // ...
    return {
      name: { type: 'UTF8' },
      quantity: { type: 'INT64' },
      price: { type: 'DOUBLE' },
      date: { type: 'TIMESTAMP_MILLIS' },
      in_stock: { type: 'BOOLEAN' }
    }
}
printSchema(jsonObj)