Files
tecamino-json_data/jsonData.go
Adrian Zürcher 85bd8de2a2 add files
2025-04-25 18:56:27 +02:00

38 lines
760 B
Go

package models
type JsonData struct {
Get *[]Get `json:"get,omitempty"`
Set *[]Set `json:"set,omitempty"`
Subscribe *[]Subscribe `json:"subscribe,omitempty"`
Subscribed *[]Subscribed `json:"subscribed,omitempty"`
Unsubscribe *[]Subscribe `json:"unsubscribe,omitempty"`
Publish *[]Publish `json:"publish,omitempty"`
}
func NewRequest() *JsonData {
return &JsonData{}
}
func (r *JsonData) AddGet(path string, query Query) {
if r.Get == nil {
r.Get = &[]Get{}
}
*r.Get = append(*r.Get, Get{
Path: path,
Query: &query,
})
}
func (r *JsonData) AddSet(path string, value any, create bool) {
if r.Set == nil {
r.Set = &[]Set{}
}
*r.Set = append(*r.Set, Set{
Path: path,
Value: value,
})
}