JSPM

redistojson

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q9013F
  • License ISC

Converts Redis data to JSON representation

Package Exports

  • redistojson

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redistojson) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.

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