Skip to content

Commit

Permalink
Added the custom parsing case.
Browse files Browse the repository at this point in the history
  • Loading branch information
parth-dadhaniya committed Mar 15, 2024
1 parent 2524ae7 commit 8a39428
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/ottl/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ottl // import "github.com/open-telemetry/opentelemetry-collector-contri
import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
"reflect"
"strconv"
Expand Down Expand Up @@ -368,6 +369,13 @@ func (g StandardPMapGetter[K]) Get(ctx context.Context, tCtx K) (pcommon.Map, er
return pcommon.Map{}, err
}
return m, nil
case string:
var jsonData pcommon.Map
errUnmarshal := json.Unmarshal([]byte(val.(string)), &jsonData)
if errUnmarshal != nil {
return pcommon.Map{}, errUnmarshal
}
return jsonData, nil
default:
return pcommon.Map{}, TypeError(fmt.Sprintf("expected pcommon.Map but got %T", val))
}
Expand Down

0 comments on commit 8a39428

Please sign in to comment.