问题
Input JSON
{
"sId": "1000000000000000",
"lat": "12.934638",
"lon": "77.693950",
"status": "up",
"last_change": 1503452208
}
My design spec:
[
{
"operation":"shift",
"spec":{
"Id":"Id",
"status":"status",
"last_change":"last_change",
"lat":{
"@(2,lat)":{
"@(2,lat)":"geocoordinate.coordinates[0]"
}
},
"lon":{
"@(2,lon)":{
"@(2,lon)":"geocoordinate.coordinates[1].",
"#Point":"geocoordinate.type"
}
}
}
}
]
as lat long is coming as string but in output i want to have it as float. i tried conversion function but couldn't get expected result. please help me to change the lat long value into float.
回答1:
Use a "modify" as your first operation to do the type conversion first, then do you shift.
Spec
[
{
"operation": "modify-overwrite-beta",
"spec": {
"lat": "=toDouble",
"lon": "=toDouble"
}
}
]
Also type conversion example here http://jolt-demo.appspot.com/#modify-typeConversion
来源:https://stackoverflow.com/questions/46224488/jolt-change-string-to-float