Http request : lost Decimals when I get data from server

Hi,

I used Http request to get data from API.
But when there are decimal numbers in the data, the robot rounds the numbers and cancels the decimal places
Is there a way to prevent this thing?

Thanks.
Bakr


update:

I used Http request to get data from Server.
after that I print response string to see if there Decimals number in string and I found :smiley:
after that I use this function jsonConvert.DeserializeObject(of DataTable)(normalResponse)
to convert response string to DataTable.
but in this step the robot round all decimal number and all decimals

this is image now:

  1. Json string befor converting to DT, if you remark I have 548.8 value

  2. Data table value after use DeserializeObject function, if you remark I have 549 value now

@Mohammed_Bakr

It’s difficult to say with this limited information
When you have a issue, better to provide some screenshots regarding the issue and desired output

Thanks

can you let us know how you are extracting the value from Json object.

yes you are right

I will re run robot and add images and more details

yes you are right

I will re run robot and add images and more details

I update question my friend

Dear I updated question.

Hi Mohammed, this is what I found online:

Declare the Json Serializer settings to handle floats…

string jsonString = "[{\"Column1\":1.0,\"Column2\":0.0,\"Column3\":1.0}]";

JsonSerializerSettings settings = new JsonSerializerSettings
        {
            FloatParseHandling = FloatParseHandling.Decimal
        };

and supply the settings when deserialising…

var dt = JsonConvert.DeserializeObject<DataTable>(jsonString, settings);

Reference: c# - JSon content Deserialization to DataTable wrongly parsing DataType - Stack Overflow

Does this help?

great, thank you very much , I will try now and tell you the results

but I need to convert your code to VB right?

can anyone help me in this step also?

this is right VB code?

Private Sub SurroundingSub()
Dim jsonString As String = “[{”“Column1"”:1.0,““Column2"”:0.0,”“Column3"”:1.0}]"
Dim settings As JsonSerializerSettings = New JsonSerializerSettings With {
.FloatParseHandling = FloatParseHandling.Decimal
}
End Sub

I created a new variable with JsonSerializerSetting type an called it jsonSettings.
after that I gave it this value
NewJsonSerializerSettings With {.FloatParseHandling = FloatParseHandling.Decimal} by Assign activity.

then I use this function to convert json response from string to DT
jsonConvert.DeserializeObject(of DataTable)(normalResponse,jsonSettings)

but unfortunately I still have the same problem

Any other advice?

@lukasziebold @Srini84 @Sugumar8785

any help please

Hi, how about this:

SampleSettings = New Newtonsoft.Json.JsonSerializerSettings

SampleSettings.FloatParseHandling = FloatParseHandling.Decimal

SampleDataTable = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(SampleJsonString,SampleSettings)

These are all in Assign activities.
Does this help?

thank you bro,
but unfortunately also this function didn’t work

It did for me! I’ll get back to you :slight_smile:

Here is my sample:

JsonDataTableParse.xaml (6.4 KB)

Happy Automating :robot: