How to add data type

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.

Hi @Pretty,

You can use “type converter” snap to add/modify data type, let me know how it goes.

1 Like

@Pretty , in the given sample data all the values are type String. You can use Type Inspector snap for this.

1 Like

hello @darshthakkar @ljupcho_machkovski

Thanks for your quick response.

Type converter and type inspector snaps are not available in our snaplogic so is there any alternative method or snaps to achieve this?

@Pretty - I think we need a bit more description of what you’re trying to do here. If you just want to convert $Id to a number, you can use the built-in expression language function parseInt($Id) in a Mapper snap.

As @ljupcho_machkovski pointed out, everything else is a String. JSON only supports a small number of data types: String, Number, Object, Array, or Boolean.

1 Like

@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.

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.

1 Like

Agreed, you can use a mapper for conversion to integer, string (fieldname.toString())

1 Like

@darshthakkar @koryknick

Noted

Thank you for your response

1 Like