Documentation ¶
Index ¶
- Variables
- func TransFromByHidingDateFieldsFromIModel(v reflect.Value, includeCUDDates bool) map[string]interface{}
- func Transform(data map[string]interface{}, f *JSONFields, permType Permission) map[string]interface{}
- type Field
- type JSONFieldBlock
- type JSONFieldEmptyList
- type JSONFieldEmptyString
- type JSONFields
- type Permission
Constants ¶
This section is empty.
Variables ¶
var ModelNameToTypeStringMapping = make(map[string]string)
ModelNameToTypeStringMapping maps name of the IModel to TypeString This is for "href" field of the JSON output Both pointer and nonpointer type names are stored
Functions ¶
func TransFromByHidingDateFieldsFromIModel ¶
func TransFromByHidingDateFieldsFromIModel(v reflect.Value, includeCUDDates bool) map[string]interface{}
TransFromByHidingDateFieldsFromIModel does some default transformation the package provides Without user defining a model comforming to IHasPermissions interface It doesn't respect all json tag, but naming and omitempty does The reason we choose to traverse IModel is because I want to fill the "href" field This picks all the stuff from the IModel to a map We don't run JSON marshalling library this stage. It is expect it to be run on the map
func Transform ¶
func Transform(data map[string]interface{}, f *JSONFields, permType Permission) map[string]interface{}
Transform performs the following: 1. Cehrry pick only fields we want by the fields specifier when given a json string, I cannot cherry pick struct, because I can't make it generic enough to fit all models Then that means I have to loop the array to json marshal it 2. Transform the value if necessary (used to be called JSONCherryPickFields)
Types ¶
type JSONFieldBlock ¶
type JSONFieldBlock bool
JSONFieldBlock is defined for field that should be blocked when PermissionBlackList is used TODO: doesn't work yet
type JSONFieldEmptyList ¶
type JSONFieldEmptyList bool
JSONFieldEmptyList is defined for field should be an empty list if no value exists TODO: need to check if this works
type JSONFieldEmptyString ¶
type JSONFieldEmptyString bool
JSONFieldEmptyString is defined for field should be an empty string if no value exists TODO: need to check if this works
type JSONFields ¶
type JSONFields map[string]interface{}
JSONFields is the fields we specify to pick out only the JSON fields we want
type Permission ¶
type Permission int
Permission of the JSON parsing
const ( // PermissionWhiteList means blocking all fields by default blocked, only specify those that are there PermissionWhiteList Permission = iota // PermissionBlackList means allow fields by default allowed, but make transformation to certain field // including to block it (not supported yet) PermissionBlackList )