You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.0 KiB

// ------------------------------------------------------------------------
// Project atila
// Active Thing (activething.com) git.activething.com/go
//
// File name main.go
// Created by DEV
// Modified 16/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 main
import (
"activething.com/go/gogo/core/errs"
"activething.com/go/gogo/packs"
"activething.com/go/gogo/packs/pjson"
"fmt"
"time"
)
func main() {
pk := pjson.NewPacker()
slc2 := [][]int16 {{1,2,3,4},{16,26,36,46}}
//slc2:= [][]int16 {{}}
slc2 = append(slc2,slc2 ...)
pk.PackMap(func(mp packs.MapPacker) {
mp.KeyValue("fb0",slc2)
mp.KeyValueList("l01",func(l packs.ListPacker){
l.ItemList(func(l1 packs.ListPacker){
l1.ItemUInt64(11)
l1.ItemUInt64(22)
})
l.ItemList(func(l1 packs.ListPacker){
l1.ItemUInt64(33)
l1.ItemUInt64(44)
})
})
mp.KeyValueBool("boolean",true)
mp.KeyValueFloat32("bf",12223234.34234)
mp.KeyValueBinary("binary",[]byte{22,121,21,23,23,54,67})
mp.KeyValueDate("date",time.Now())
mp.KeyValueInt16("una",34)
/*
mp.KeyValueObject("MiObjeto",func(op packs.ObjectPacker){
op.FieldInt32("fb1",43433)
op.FieldString ("fb2","aaaaa")
op.Field("fb3",slc)
})
*/
})
errs.Test(pk.Error(),true)
fmt.Printf("JSON \n%s",pk.Bytes())
}

Powered by TurnKey Linux.