Skip to content

[pkg/ottl]: Add Double converter #22056

Closed
@kamalmarhubi

Description

@kamalmarhubi

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

There's currently an Int converter, but no obvious way to force a value to be a Double. If you have an attribute that's a string representation of a double, it'd be nice to just parse it the way you currently for string representations of integers with Int.

Describe the solution you'd like

Add a Double converter that can convert Double, Int, String values.

Describe alternatives you've considered

The best I've come up with is going via JSON:

ParseJSON(Concat(["{\"value\":", attributes["some_attr"], "}"], ""))["value"]

which does in fact work for Double, Int, and String.

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions