Forum Discussion
@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.
Agreed, you can use a mapper for conversion to integer, string (fieldname.toString())
- darshthakkar3 years agoValued Contributor
Hi @Pretty,
You can use “type converter” snap to add/modify data type, let me know how it goes.
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?
- ljupcho_machko13 years agoNew Contributor III
@Pretty , in the given sample data all the values are type String. You can use Type Inspector snap for 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.
- darshthakkar3 years agoValued Contributor
Agreed, you can use a mapper for conversion to integer, string (fieldname.toString())
@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.
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
Related Content
- 6 months ago
- 5 months ago
- 11 months ago
- 11 months ago