Giter VIP home page Giter VIP logo

rmarshal's Introduction

rmarshal

dump and load ruby marshal data via lua, and equal to ruby marshal format

Requirements

luajit

Demo

dump in Ruby

h = {
   _csrf_token: "l6xLJ5cJN59jgx7H5y9BO6jsjyZ9dr0kMpmcMr7H+p4=",
   db_id: 5,
   return_to: "/",
   session_id: "90ea8d4b7a331fa8a8a49b2a26beefde",
   user_id: 4
 }
s = Marshal.dump(h) #=> "\x04\b{\nI\"\x0Ereturn_to\x06:\x06EF\"\x06/I\"\x0Fsession_id\x06;\x00FI\"%90ea8d4b7a331fa8a8a49b2a26beefde\x06;\x00TI\"\x10_csrf_token\x06;\x00FI\"1l6xLJ5cJN59jgx7H5y9BO6jsjyZ9dr0kMpmcMr7H+p4=\x06;\x00FI\"\fuser_id\x06;\x00Fi\tI\"\ndb_id\x06;\x00Fi\n7"

load in Lua

local inspect = require("inspect")
local rmarshal = require("rmarshal")
local t = rmarshal:load(s)
print(inspect(t))
-- =>
-- {
--   _csrf_token = "l6xLJ5cJN59jgx7H5y9BO6jsjyZ9dr0kMpmcMr7H+p4=",
--   db_id = 5,
--   return_to = "/",
--   session_id = "90ea8d4b7a331fa8a8a49b2a26beefde",
--   user_id = 4
-- }

That's ALL, JUST DO IT!!!

rmarshal's People

Contributors

wxianfeng avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.