Skip to content

Question on joining as one string #388

Description

@isyca

Sorry. i cannot find any discussion / discord.

	json := `{
		"name": {"first": "Tom", "last": "Anderson"},
		"age":37,
		"children": ["Sara","Alex","Jack"],
		"fav.movie": "Deer Hunter",
		"friends": [
			{"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
			{"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
			{"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
		]
	}`

	value := gjson.Get(json, "name.first|@join|age")
	println(value.String()) 	// this prints nothing. I am looking to print it "Tom37" just like below
	
	val1 := gjson.Get(json, "name.first")
	val2 := gjson.Get(json, "age")
	println(val1.String()+ val2.String())

I am looking for a single path that will result to (in this example) "Tom37"

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions