Add intermediate parsing step
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2019-02-08 23:25:12 +01:00
parent 255d56d167
commit 0147c599a8
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -209,7 +209,7 @@ func simplifyCardFromString(card microsub.Card, value string) (microsub.Card, bo
return card, false
}
func simplifyCardFromProperties(card microsub.Card, properties map[string]interface{}) (microsub.Card, bool) {
func simplifyCardFromProperties2(card *microsub.Card, properties map[string]interface{}) {
for ik, vk := range properties {
if arr, ok := vk.([]interface{}); ok {
if p, ok := arr[0].(string); ok {
@ -236,6 +236,25 @@ func simplifyCardFromProperties(card microsub.Card, properties map[string]interf
}
}
}
}
func simplifyCardFromProperties(card microsub.Card, hcard map[string]interface{}) (microsub.Card, bool) {
for ik, vk := range hcard {
if arr, ok := vk.([]interface{}); ok {
switch ik {
case "type":
if p, ok := arr[0].(string); ok {
card.Type = p[2:]
}
case "properties":
if p, ok := arr[0].(map[string]interface{}); ok {
simplifyCardFromProperties2(&card, p)
}
default:
log.Printf("In simplifyCardFromProperties: unknown property %q with value %q\n", ik, arr[0])
}
}
}
return card, true
}