Giter VIP home page Giter VIP logo

Comments (4)

Andrew-M-C avatar Andrew-M-C commented on August 25, 2024

你看看这个是不是符合你的需求:
按照原字节流顺序或 key 被设置的顺序序列化

from go.jsonvalue.

Andrew-M-C avatar Andrew-M-C commented on August 25, 2024

此外,这里也是相关的一个功能:
获取 object 类型值的原始顺序

如果觉得还不清晰的话,你可以列出你的代码,并且描述一下你预期的结果?

from go.jsonvalue.

Andrew-M-C avatar Andrew-M-C commented on August 25, 2024

你可以参考一下我给你的例子,应该可以解答你的疑问: @fkepesc

https://go.dev/play/p/1fMg1bnr-p1

from go.jsonvalue.

Andrew-M-C avatar Andrew-M-C commented on August 25, 2024

为防止墙,贴上代码:

package main

import (
	"fmt"

	jsonvalue "github.com/Andrew-M-C/go.jsonvalue"
)

func main() {
	const raw = `{"alpha":"12345","beta":"ABCDE"}`
	v := jsonvalue.MustUnmarshalString(raw)

	// 获取 object 类型值的原始顺序
	// 必然永远是:
	// 0 alpha 12345
	// 1 beta ABCDE
	i := 0
	v.RangeObjectsBySetSequence(func(key string, v *jsonvalue.V) bool {
		fmt.Println(i, key, v)
		i++
		return true
	})

	// 按照原字节流顺序或 key 被设置的顺序序列化
	// 必然永远是:
	// {"alpha":"12345","beta":"ABCDE"}
	s := v.MustMarshalString(jsonvalue.OptSetSequence())
	fmt.Println(s)
}

from go.jsonvalue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.