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

Unexpected Array Wrapping #6

Open
zblach opened this issue Aug 1, 2017 · 0 comments
Open

Unexpected Array Wrapping #6

zblach opened this issue Aug 1, 2017 · 0 comments

Comments

@zblach
Copy link

zblach commented Aug 1, 2017

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]]
@zblach zblach changed the title Inconsistent Array Wrapping Unexpected Array Wrapping Aug 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant