+
+ set_error(s, "<args>", json_error_null_value, "NULL object");
+ s->has_error = 1;
+ return NULL;
+}
+
+static json_t *pack_integer(scanner_t *s, json_int_t value)
+{
+ json_t *json = json_integer(value);
+
+ if (!json) {
+ set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");
+ s->has_error = 1;
+ }
+
+ return json;
+}
+
+static json_t *pack_real(scanner_t *s, double value)
+{
+ /* Allocate without setting value so we can identify OOM error. */
+ json_t *json = json_real(0.0);
+
+ if (!json) {
+ set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");
+ s->has_error = 1;
+
+ return NULL;
+ }
+
+ if (json_real_set(json, value)) {
+ json_decref(json);
+
+ set_error(s, "<args>", json_error_numeric_overflow, "Invalid floating point value");
+ s->has_error = 1;
+
+ return NULL;
+ }
+
+ return json;