Skip to content

Faker helper stringifies arrays and objects which makes some values impossible to use with other helpers #880

@255kb

Description

@255kb

faker helper behavior is to stringify arrays and objects.
Considering the recent improvements to helpers in general (avoiding stringifying to maximize compatibility between helpers) this should be changed.

Multiple possibilities:

  • add a new helper fakerRaw not stringifying the results.
  • add a new param (named) if possible.
  • remove the stringify. This would cause a breaking change which impact should be assessed.

Discussed in #879

Originally posted by sureMOISE December 6, 2022
is it possibile to get the value from a variable array?
example:

{{setVar 'refLat' (faker 'address.latitude' 46.722873 46.713458 8)}}
{{setVar 'refLong' (faker 'address.longitude' 8.121358 8.102806 8)}}
{{setVar 'coords' (faker 'address.nearbyGPSCoordinate' (array (parseInt @refLat) ( parseInt @refLong)) 1 true)}}

the variable @coords return ['46.722873', '8.102806'] and I need to retrive the first and the second value in an object, in something like:

{
  "latitude": {{{@coords[0]}}},
  "longitude":  {{{@coords[1]}}}
}

the final result should be:

{
  "latitude": 46.722873,
  "longitude":  8.102806
}

any idea? thanks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done (ready for next release)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions