Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Unexpected Array Wrapping #6

@zblach

Description

@zblach

I'm not sure if this is a bug in this or libucl proper, but there seems to be some inconsistency when it comes to serialization and deserialization of maps.

ex := `name: example
rank: 5
cereal: {
  "frosted flakes" {
  	good: true
  }
  "capn crunch" {
  	good: true
  }
  "special K" {
  	good: false
  }
}`

var uclconf, jsonconf map[string]interface{}
obj, _ := ucl.ParseString(ex)
obj.Decode(&uclconf)

js, _ := obj.Emit(ucl.EmitJSONCompact) // or EmitJSON
json.Unmarshal([]byte(js), &jsonconf)

uclcereal := uclconf["cereal"].([]map[string]interface{})[0]
jsoncereal := jsonconf["cereal"].(map[string]interface{})

fmt.Println(uclcereal)
fmt.Println(jsoncereal)

output:

map[special K:[map[good:false]] frosted flakes:[map[good:true]] capn crunch:[map[good:true]]]
map[frosted flakes:map[good:true] capn crunch:map[good:true] special K:map[good:false]]

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