Custom JSON serializer and parser.
Install package:
$ npm install --save lucid.js
Usage:
import lucid from 'lucid.js';
lucid.serialize({
name: "slam dunk",
topic: ["arcade", "basketball"],
player: [
{ id: "6c4d0e6a", name: "Billie Ko" },
{ id: "e19148f8", name: "Zion" }
],
tag: {
maxPlayers: 5
}
})
// name:"slam dunk",topic:(arcade basketball),player:("Billie Ko<6c4d0e6a>" Zion<e19148f8>),tag.maxPlayers:5
lucid.parse('game:pacman,enemies:(red "dark blue"),players:(Luigi<luigi> "Super Mario<mario>" princess),lvl.difficult:true')
/*
{
game: 'pacman',
enemies: ['red', 'dark blue'],
players: [
{ id: 'luigi', name: 'Luigi' },
{ id: 'mario', name: 'Super Mario' },
'princess'
],
lvl: {
difficult: true
}
}
*/
{
bar: "coin",
coins: 5000,
flag: false
}
Output:
bar:coin,coins:5000,flag:false
{
bar: ["power up", 7, true]
}
Output:
bar:("power up" 7 true)
{
game: {
name: "Super Mario Bros",
numPlayers: 2
}
}
Output:
game.name:"Super Mario Bros",game.numPlayers:2
{
game: [
{
id: "642c0926",
name: "Super Mario Bros"
},
{
id: "e19148f8",
name: "Arcade Basketball",
bar: "This is not going to be included!"
}
]
}
Output:
game:("Super Mario Bros<642c0926>" "Arcade Basketball<e19148f8>")
{
foo: [[1, 2, 3]]
}
{
foo: {
bar: {}
}
}
{
foo: [
{
baz: "Not good!"
}
]
}