Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.28 KB

README.org

File metadata and controls

37 lines (25 loc) · 1.28 KB

jzon-util

These are utilities for using com.inuoe.jzon

Functionality

sensitive-metaclass

This provides a slot option called :sensitve which will make that slot not be json encoded.

To check if a slot is sensitve do sensitive-slot-value on a given slot.

(ql:quickload "com.inuoe.jzon")

(defclass c1 ()
  ((name :accessor name :initarg :name :initform nil)
   (secret :accessor secret :initarg :secret :initform nil)
   (hello :accessor hello :initarg :hello :initform nil)))

(com.inuoe.jzon:stringify (make-instance 'c1 :name "john" :secret "hello world!" :hello "Miami"))
;; "{\"name\":\"john\",\"secret\":\"hello world!\",\"hello\":\"Miami\"}"

(ql:quickload "jzon-util")

(defclass c3 ()
  ((name :accessor name :initarg :name :initform nil)
   (secret :accessor secret :initarg :secret :initform nil :sensitive t)
   (hello :accessor hello :initarg :hello :initform nil))
  (:metaclass jzon-util:sensitive-metaclass))

(com.inuoe.jzon:stringify (make-instance 'c3 :name "john" :secret "hello world!" :hello "Miami"))
;; "{\"name\":\"john\",\"hello\":\"Miami\"}"

Notice that the second time, the secret was not encoded in the json.

TODO make this depends on cl-sensitive and remove the duplicated code