# JSON module registers a map function to allow mapping fields from JSON
# structures to attributes.
#
-# The path through the JSON document's tree is specified with FR jpath,
+# The path through the JSON document's tree is specified with FR jpath,
# which is the FreeRADIUS implementation of the jpath grammar described here:
#
# http://goessner.net/articles/JsonPath/
#
# Automatic casting will occur between JSON and attribute types where possible.
#
-# FreeRADIUS does not currently have a signed64 or floating point type, to map
-# large signed numbers and JSON doubles to. These may instead be written to
-# string type attributes.
-#
# Assignment of JSON objects/arrays to strings is supported, in which case the
# JSON serialized form of the object/array is used.
#
num = json_object_get_int(object);
#else
num = json_object_get_int64(object);
- if (num < INT32_MIN) { /* 64bit signed (not supported)*/
- fr_strerror_printf("Signed 64bit integers are not supported");
- return -1;
- }
- if (num > UINT32_MAX) { /* 64bit unsigned (supported) */
+ if (num < INT32_MIN) { /* 64bit signed*/
+ in.type = FR_TYPE_INT64;
+ in.vb_int64 = (int64_t) num;
+ } else if (num > UINT32_MAX) { /* 64bit unsigned */
in.type = FR_TYPE_UINT64;
in.vb_uint64 = (uint64_t) num;
} else
#endif
- if (num < 0) { /* 32bit signed (supported) */
+ if (num < INT16_MIN) { /* 32bit signed */
in.type = FR_TYPE_INT32;
- in.vb_int32 = num;
- } else if (num > UINT16_MAX) { /* 32bit unsigned (supported) */
+ in.vb_int32 = (int32_t)num;
+ } else if (num < INT8_MIN) { /* 16bit signed */
+ in.type = FR_TYPE_INT16;
+ in.vb_int16 = (int16_t)num;
+ } else if (num < 0) { /* 8bit signed */
+ in.type = FR_TYPE_INT8;
+ in.vb_int8 = (int8_t)num;
+ } else if (num > UINT16_MAX) { /* 32bit unsigned */
in.type = FR_TYPE_UINT32;
in.vb_uint32 = (uint32_t) num;
- } else if (num > UINT8_MAX) { /* 16bit unsigned (supported) */
+ } else if (num > UINT8_MAX) { /* 16bit unsigned */
in.type = FR_TYPE_UINT16;
in.vb_uint16 = (uint16_t) num;
- } else { /* 8bit unsigned (supported) */
+ } else { /* 8bit unsigned */
in.type = FR_TYPE_UINT8;
in.vb_uint8 = (uint8_t) num;
}