Skip to content

Ade-Joshe/Redis-to-JSON-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redistojson
# Redis-to-JSON-converter Converts Redis data to JSON representation

For those seeking a means to convert redis "string" data to JSON object for easy parsing.

Special Thanks to my friend, Augustine Best and also Jerry for their amazing contributions and My boss Okoye Emmanuel for tasking us with the solution to the pending redis problem. it's good to work with great minds @geneystechhub

How to use

step 1: Install reformat-date

npm install redistojson --save

step 2: Require the package in your project

const redistojson = require('redistojson');

step 3: Pass in the redis data you wish to convert as an argument
-for example
case 1: having a list of persons data

const redisData = "Persons,[name,adegoke,address,gentlemen in ikorodu,age,90,sex,masculine,pet,Bethy,wife,Mai,school,],[name,Augustine Best,address,Enugu,age,32,sex,male,pet,Cowboy,wife,Juin,school,FUTO],[name,Femi,address,Surulere,age,45,sex,male,pet,Cat,wife,Queen,school,UNILAG],[name,Peter,address,Ikeja,age,23,sex,male,pet,Dog,wife,Angela,school,OAU],[name,Betty,address,Porharcourt,age,21,sex,female,pet,Elephant,wife,princess,school,UNIBEN],[name,Jessie,address,Toronto,age,49,sex,male,pet,Goat,wife,Stephanie,school,Harvard]";

console.log(redistojson(redisData));

// result 
{
  Persons: [
    {
      name: 'adegoke',
      address: 'gentlemen in ikorodu',
      age: '90',
      sex: 'masculine',
      pet: 'Bethy',
      wife: 'Mai',
      school: ''
    },
    {
      name: 'Augustine Best',
      address: 'Enugu',
      age: '32',
      sex: 'male',
      pet: 'Cowboy',
      wife: 'Juin',
      school: 'FUTO'
    },
    {
      name: 'Femi',
      address: 'Surulere',
      age: '45',
      sex: 'male',
      pet: 'Cat',
      wife: 'Queen',
      school: 'UNILAG'
    },
    {
      name: 'Peter',
      address: 'Ikeja',
      age: '23',
      sex: 'male',
      pet: 'Dog',
      wife: 'Angela',
      school: 'OAU'
    },
    {
      name: 'Betty',
      address: 'Porharcourt',
      age: '21',
      sex: 'female',
      pet: 'Elephant',
      wife: 'princess',
      school: 'UNIBEN'
    },
    {
      name: 'Jessie',
      address: 'Toronto',
      age: '49',
      sex: 'male',
      pet: 'Goat',
      wife: 'Stephanie',
      school: 'Harvard'
    }
  ]
}

case 2: having an object of a data

const redisData = "Person,name,adegoke,address,gentlemen in ikorodu,age,90,sex,mascufeline,pet,Bethy,wife,Mai,school,";

console.log(redistojson(redisData)); 

// result
{
  Person: {
    name: 'adegoke',
    address: 'gentlemen in ikorodu',
    age: '90',
    sex: 'mascufeline',
    pet: 'Bethy',
    wife: 'Mai',
    school: ''
  }
}

All the best

About

Converts Redis data to JSON representation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published