decodeFieldsObject reads a JSON object from raw, accepting the direct object form and the JSON-encoded string the agent flattener produces when it stringifies a nested object into a "--fields" argv value.
(raw json.RawMessage)
| 383 | // object form and the JSON-encoded string the agent flattener produces when |
| 384 | // it stringifies a nested object into a "--fields" argv value. |
| 385 | func decodeFieldsObject(raw json.RawMessage) map[string]interface{} { |
| 386 | var direct map[string]interface{} |
| 387 | if err := json.Unmarshal(raw, &direct); err == nil { |
| 388 | return direct |
| 389 | } |
| 390 | var s string |
| 391 | if err := json.Unmarshal(raw, &s); err != nil { |
| 392 | return nil |
| 393 | } |
| 394 | var inner map[string]interface{} |
| 395 | if err := json.Unmarshal([]byte(s), &inner); err != nil { |
| 396 | return nil |
| 397 | } |
| 398 | return inner |
| 399 | } |
| 400 | |
| 401 | // stringifyMap coerces JSON values to strings (numbers/bools become text; |
| 402 | // arrays are joined with commas so list fields round-trip). |
no outgoing calls
no test coverage detected