How is request.data serialized?

I’m doing some testing in Pre-request Script. In that tab, I have access to request.data which I understand to be the data payload being POST’d (in the case of a POST for example).

I have also confirmed that request.data appears to be a string (via typeof request.data).

Given example data:

[
    'fname': 'Joe',
    'lname': 'blogs'
]

If I paste the above data in the “body”. Then in Pre-request Script tab I assign the same object to variable user:

var user = ['fname': 'Joe', 'lname': 'blogs']

I notice that request.data.length does not seem to equal JSON.stringify(user).length

So I’m curious, how is request.data serialized?

user is an array of 2 elements , so length is 2

JSON.stringify(user) is string representation of the array, and when you call length you are printing the number of charaters in the string