Can't seem to get booleans out of JSON and into database

1097
1
12-09-2020 07:29 AM
MikeQuetel1
Occasional Contributor

Hi,

I'm polling for JSON and inserting/updating a SQL Server backed feature class.  It's mostly working... I'm getting features into the database, but I just can't seem to handle the booleans  in the JSON correctly.  

There is sample data from the feed at the bottom of this post... for example, the "has_kisosk" field is going to be true/false.

The input geoevent definition has that field as a bool, and if I write that event directly out to JSON, the value comes across fine. Getting it into the database is the problem.  My database schema is a bit different in terms of field names.  Also, booleans are stored as smallint or bit fields in SQL Server (I'm using smallint).

So, my output geoevent defintion has the boolean field as type "short"and I use a field mapper to make that transformation from input to output geoevent defintion.

The problem is that all boolean fields come across as null from the output geoevent def.  This is consistent in the database as well as if I write this output geoevent defintion to JSON.  If I make the output geoevent defintion also use type "boolean" then I can see the values in my output JSON, but the feature service records the following in the ArcGIS server log:

 

 

Error: The value type is incompatible with the field type. [HAS_KIOSK].

 

 

So it seems like booleans aren't being automatically transformed into shorts (or other integer types).  Can anyone provide some pointers on how to handle this?

Thanks in advance!

 

 

 

{
	"data": {
		"stations": [{
			"lat": 45.51898132,
			"rack_model": "CITY_PILOT_RACK",
			"legacy_id": "1440914125193298376",
			"address": "Park Avenue West, Southwest Yamhill Street, Portland",
			"region_code": "PDX",
			"name": "SW Yamhill at Director Park",
			"eightd_station_services": [],
			"rental_uris": {
				"android": "https://pdx.lft.to/lastmile_qr_scan",
				"ios": "https://pdx.lft.to/lastmile_qr_scan"
			},
			"capacity": 20,
			"eightd_has_key_dispenser": false,
			"station_id": "1440914125193298376",
			"lon": -122.6812685,
			"station_type": "lightweight",
			"has_kiosk": false,
			"electric_bike_surcharge_waiver": false,
			"external_id": "motivate_PDX_1440914125193298376",
			"dockless_bikes_parking_zone_capacity": 20,
			"client_station_id": "motivate_PDX_1440914125193298376"
		}]
	}
}

 

 

 

 

0 Kudos
1 Reply
EricIronside
Esri Regular Contributor

Hey @MikeQuetel1 

Booleans should be handled as either String or a numeric number (depending on your feature service and how you set it up).  Import the GeoEvent Definition from the Feature Service you are writing to (delete the OBJECTID, GUID, and any other managed fields) then use a field mapper to map your events into that defintion before writing out to your feature service.  If your fields are numeric, you'll need to use a field calculator before the field mapper to convert boolean into numeric. for boolean fields, I recommend you use a string because you can map a boolean field to a string field directly in the Field Mapper.

0 Kudos