08-17-2022 05:24 AM
We have Json file as input source which some random data for that values we need to add datatypes.
Sample data:
{
“Id”: “1076”,
“jobTitle”: “Software engineer”,
“firstName”: “David”,
“lastName”: “villey”,
“fullName”: “Davidvilley”,
“email_N”: “Davidvilley@gmail.com”,
“telephoneNumber”: “+1-8474987109”
}
Please help me to add the datatypes for above data to validate.
08-17-2022 07:01 AM
@koryknick @darshthakkar @ljupcho_machkovski
Here exactly I am working on ,
We have data in json file.
{
“Id”: “1076”,
“jobTitle”: “Software engineer”,
“firstName”: “David”,
“lastName”: “villey”,
“fullName”: “Davidvilley”,
“email_N”: “Davidvilley@gmail.com”,
“telephoneNumber”: “+1-8474987109”
}
those are the data which I mentioned above,
firstly we will import this data from json file , But here we don’t have any datatype for this data so I need to add datatypes, from adding the datatype I can validate the data.
For example If we add the datatype for firstName as string(4) in this case If we pass 5 character ex:David It should through an error. I need to store this error msg in separate output so to get this result i am trying to add the datatypes.
I hope this make sense.
Thanks in advance.
08-17-2022 08:09 AM
Agreed, you can use a mapper for conversion to integer, string (fieldname.toString())
08-17-2022 09:16 AM
08-17-2022 07:06 AM
There is a Data Validator snap in the Flow snap pack, which is Public so you have access to it. As I stated, JSON supports a limited set of data types and does not restrict length or precision, so the Data Validator is probably your best bet.
03-20-2023 09:56 AM
Hi @Pretty
Good day… 😀
{
"Id": 1076,
"this_is_an_array": [1, 2, 3, 4, 88],
"this_is_an_object": {
"key": "val"
},
"jobTitle": "Software engineer",
"firstName": "David",
"lastName": "villey",
"fullName": "Davidvilley",
"email_N": "Davidvilley@gmail.com",
"telephoneNumber": "+1-8474987109",
"this_is_a_boolean": true
}.mapValues((val, key) => {'type': val}.mapKeys((v, k) => typeof v))
This outputs the type as keyname
Hope this helps
Thanks,
EmEm