parent
4e905ce64b
commit
a6b80c0dac
@ -0,0 +1,35 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name builder.go
|
||||
// Created by DEV
|
||||
// Modified 21/01/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package jjson
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name state.go
|
||||
// Created by DEV
|
||||
// Modified 21/01/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package jjson
|
||||
|
||||
|
||||
|
||||
@ -1,116 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name BuilderObject.go
|
||||
// Created by DEV
|
||||
// Modified 18/01/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package pjson
|
||||
|
||||
import (
|
||||
"activething.com/go/gogo/packs"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (p *Builder) FieldAny (name string, value any) {
|
||||
if p.addName(name) {
|
||||
p.Any(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldBinary (name string, value []byte){
|
||||
if p.addName(name) {
|
||||
p.Binary(value)
|
||||
}
|
||||
}
|
||||
func (p *Builder) FieldString (name string, value string){
|
||||
if p.addName(name) {
|
||||
p.String(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldBool (name string, value bool ){
|
||||
if p.addName(name) {
|
||||
p.Bool(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldRune (name string, value rune ){
|
||||
if p.addName(name) {
|
||||
p.Rune(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldInt8 (name string, value int8 ){ p.FieldInt64(name, int64(value)) }
|
||||
func (p *Builder) FieldInt16 (name string, value int16 ){ p.FieldInt64(name, int64(value)) }
|
||||
func (p *Builder) FieldInt32 (name string, value int32 ){ p.FieldInt64(name, int64(value)) }
|
||||
func (p *Builder) FieldInt64 (name string, value int64 ){
|
||||
if p.addName(name) {
|
||||
p.Int64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldUInt8 (name string, value uint8 ){ p.FieldUInt64(name, uint64(value)) }
|
||||
func (p *Builder) FieldUInt16 (name string, value uint16){ p.FieldUInt64(name, uint64(value)) }
|
||||
func (p *Builder) FieldUInt32 (name string, value uint32){ p.FieldUInt64(name, uint64(value)) }
|
||||
func (p *Builder) FieldUInt64 (name string, value uint64){
|
||||
if p.addName(name) {
|
||||
p.UInt64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldFloat32(name string, value float32){ p.FieldFloat64(name, float64(value)) }
|
||||
func (p *Builder) FieldFloat64(name string, value float64){
|
||||
if p.addName(name) {
|
||||
p.Float64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldComplex64 (name string, value complex64 ){ p.FieldComplex128(name, complex128(value)) }
|
||||
func (p *Builder) FieldComplex128(name string, value complex128){
|
||||
if p.addName(name) {
|
||||
p.Complex128(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldDate (name string, value time.Time) {
|
||||
if p.addName(name) {
|
||||
p.Date(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldList (name string, builder func(packer packs.BuilderList)) {
|
||||
if p.addName(name) {
|
||||
p.List(builder)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldMap (name string, builder func(packer packs.BuilderMap)) {
|
||||
if p.addName(name) {
|
||||
p.Map(builder)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) FieldObject(name string, builder func(packer packs.BuilderObject)) {
|
||||
if p.addName(name) {
|
||||
p.Object(builder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name BuilderObject.go
|
||||
// Created by DEV
|
||||
// Modified 18/01/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package pjson
|
||||
|
||||
import (
|
||||
"activething.com/go/gogo/packs"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (p *Builder) PropAny (name string, value any) {
|
||||
if p.addName(name) {
|
||||
p.Any(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropBinary (name string, value []byte){
|
||||
if p.options.IgnoreDefaults() && len(value) == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Binary(value)
|
||||
}
|
||||
}
|
||||
func (p *Builder) PropString (name string, value string){
|
||||
if p.options.IgnoreDefaults() && len(value) == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.String(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropBool (name string, value bool ){
|
||||
if p.options.IgnoreDefaults() && !value {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Bool(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropRune (name string, value rune ){
|
||||
if p.options.IgnoreDefaults() && value == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Rune(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropInt8 (name string, value int8 ){ p.PropInt64(name, int64(value)) }
|
||||
func (p *Builder) PropInt16 (name string, value int16 ){ p.PropInt64(name, int64(value)) }
|
||||
func (p *Builder) PropInt32 (name string, value int32 ){ p.PropInt64(name, int64(value)) }
|
||||
func (p *Builder) PropInt64 (name string, value int64 ){
|
||||
if p.options.IgnoreDefaults() && value == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Int64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropUInt8 (name string, value uint8 ){ p.PropUInt64(name, uint64(value)) }
|
||||
func (p *Builder) PropUInt16 (name string, value uint16){ p.PropUInt64(name, uint64(value)) }
|
||||
func (p *Builder) PropUInt32 (name string, value uint32){ p.PropUInt64(name, uint64(value)) }
|
||||
func (p *Builder) PropUInt64 (name string, value uint64){
|
||||
if p.options.IgnoreDefaults() && value == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.UInt64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropFloat32(name string, value float32){ p.PropFloat64(name, float64(value)) }
|
||||
func (p *Builder) PropFloat64(name string, value float64){
|
||||
if p.options.IgnoreDefaults() && value == 0 {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Float64(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropComplex64 (name string, value complex64 ){ p.PropComplex128(name, complex128(value)) }
|
||||
func (p *Builder) PropComplex128(name string, value complex128){
|
||||
if p.options.IgnoreDefaults() && value == (0+0i) {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Complex128(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropDate (name string, value time.Time) {
|
||||
if p.options.IgnoreDefaults() && value.IsZero() {
|
||||
return
|
||||
}
|
||||
if p.addName(name) {
|
||||
p.Date(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropList (name string, builder func(packer packs.BuilderList)) {
|
||||
if p.addName(name) {
|
||||
p.List(builder)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropMap (name string, builder func(packer packs.BuilderMap)) {
|
||||
if p.addName(name) {
|
||||
p.Map(builder)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Builder) PropObject(name string, builder func(packer packs.BuilderObject)) {
|
||||
if p.addName(name) {
|
||||
p.Object(builder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in new issue