--- json.h.orig	2015-05-01 11:27:25.000000000 -0700
+++ json.h	2016-01-03 18:35:53.000000000 -0800
@@ -11,7 +11,8 @@
 	      t_string, t_boolean, t_character,
 	      t_time,
 	      t_object, t_structobject, t_array,
-	      t_check, t_ignore}
+	      t_check, t_ignore,
+	      t_short, t_ushort}
     json_type;
 
 struct json_enum_t {
@@ -39,6 +40,12 @@
 	    unsigned int *store;
 	} uintegers;
 	struct {
+	    short *store;
+	} shorts;
+	struct {
+	    unsigned short *store;
+	} ushorts;
+	struct {
 	    double *store;
 	} reals;
 	struct {
@@ -54,6 +61,8 @@
     union {
 	int *integer;
 	unsigned int *uinteger;
+	short *shortint;
+	unsigned short *ushortint;
 	double *real;
 	char *string;
 	bool *boolean;
@@ -64,6 +73,8 @@
     union {
 	int integer;
 	unsigned int uinteger;
+	short shortint;
+	unsigned short ushortint;
 	double real;
 	bool boolean;
 	char character;
--- json.c.orig	2015-05-01 11:27:25.000000000 -0700
+++ json.c	2016-01-03 18:37:53.000000000 -0800
@@ -128,6 +128,12 @@
 	case t_uinteger:
 	    targetaddr = (char *)&cursor->addr.uinteger[offset];
 	    break;
+	case t_short:
+	    targetaddr = (char *)&cursor->addr.shortint[offset];
+	    break;
+	case t_ushort:
+	    targetaddr = (char *)&cursor->addr.ushortint[offset];
+	    break;
 	case t_time:
 	case t_real:
 	    targetaddr = (char *)&cursor->addr.real[offset];
@@ -197,6 +203,13 @@
 		case t_uinteger:
 		    memcpy(lptr, &cursor->dflt.uinteger, sizeof(unsigned int));
 		    break;
+		case t_short:
+		    memcpy(lptr, &cursor->dflt.shortint, sizeof(short));
+		    break;
+		case t_ushort:
+		    memcpy(lptr, &cursor->dflt.ushortint,
+		           sizeof(unsigned short));
+		    break;
 		case t_time:
 		case t_real:
 		    memcpy(lptr, &cursor->dflt.real, sizeof(double));
@@ -478,6 +491,18 @@
 			memcpy(lptr, &tmp, sizeof(unsigned int));
 		    }
 		    break;
+		case t_short:
+		    {
+			short tmp = atoi(valbuf);
+			memcpy(lptr, &tmp, sizeof(short));
+		    }
+		    break;
+		case t_ushort:
+		    {
+			unsigned short tmp = (unsigned int)atoi(valbuf);
+			memcpy(lptr, &tmp, sizeof(unsigned short));
+		    }
+		    break;
 		case t_time:
 		    {
 			double tmp = iso8601_to_unix(valbuf);
@@ -645,6 +670,24 @@
 		cp = ep;
 	    break;
 #endif /* JSON_MINIMAL */
+	case t_short:
+#ifndef JSON_MINIMAL
+	    arr->arr.shorts.store[offset] = (short)strtol(cp, &ep, 0);
+	    if (ep == cp)
+		return JSON_ERR_BADNUM;
+	    else
+		cp = ep;
+	    break;
+#endif /* JSON_MINIMAL */
+	case t_ushort:
+#ifndef JSON_MINIMAL
+	    arr->arr.ushorts.store[offset] = (unsigned short)strtoul(cp, &ep, 0);
+	    if (ep == cp)
+		return JSON_ERR_BADNUM;
+	    else
+		cp = ep;
+	    break;
+#endif /* JSON_MINIMAL */
 	case t_time:
 #ifndef JSON_MINIMAL
 	    if (*cp != '"')
--- libgps_json.c.orig	2015-04-13 20:52:28.000000000 -0700
+++ libgps_json.c	2016-01-03 18:39:08.000000000 -0800
@@ -109,9 +109,9 @@
 {
     const struct json_attr_t json_attrs_satellites[] = {
 	/* *INDENT-OFF* */
-	{"PRN",	   t_integer, STRUCTOBJECT(struct satellite_t, PRN)},
-	{"el",	   t_integer, STRUCTOBJECT(struct satellite_t, elevation)},
-	{"az",	   t_integer, STRUCTOBJECT(struct satellite_t, azimuth)},
+	{"PRN",	   t_short, STRUCTOBJECT(struct satellite_t, PRN)},
+	{"el",	   t_short, STRUCTOBJECT(struct satellite_t, elevation)},
+	{"az",	   t_short, STRUCTOBJECT(struct satellite_t, azimuth)},
 	{"ss",	   t_real,    STRUCTOBJECT(struct satellite_t, ss)},
 	{"used",   t_boolean, STRUCTOBJECT(struct satellite_t, used)},
 	/* *INDENT-ON* */
--- test_json.c.orig	2015-05-01 11:27:25.000000000 -0700
+++ test_json.c	2016-01-03 18:18:10.000000000 -0800
@@ -90,7 +90,12 @@
     \"time\":\"2005-06-19T08:12:41.89Z\",\"lon\":46.498203637,\"lat\":7.568074350,\
     \"alt\":1327.780,\"epx\":21.000,\"epy\":23.000,\"epv\":124.484,\"mode\":3}";
 
-/* Case 2: SKY report */
+/*
+ * Case 2: SKY report
+ *
+ * The fields of the last satellite entry are arranged in the reverse order
+ * of the structure fields, in order to test for field overflow.
+ */
 
 static const char *json_str2 = "{\"class\":\"SKY\",\
          \"time\":\"2005-06-19T12:12:42.03Z\",   \
@@ -101,7 +106,7 @@
          {\"PRN\":26,\"el\":51,\"az\":304,\"ss\":43,\"used\":true},\
          {\"PRN\":8,\"el\":44,\"az\":58,\"ss\":41,\"used\":true},\
          {\"PRN\":27,\"el\":16,\"az\":66,\"ss\":39,\"used\":true},\
-         {\"PRN\":21,\"el\":10,\"az\":301,\"ss\":0,\"used\":false}]}";
+         {\"az\":301,\"el\":10,\"PRN\":21,\"used\":false,\"ss\":0}]}";
 
 /* Case 3: String list syntax */
 
