HELP!! parse error: Invalid numeric literal at line x, column x?! It’s not your Oracle REST API!!
A few days ago, I penned a blog post highlighting the ORDS REST-Enabled SQL Service. And in that blog, I displayed the output of a
cURL command. A
cURL command I issued to an ORDS REST-Enabled SQL Service endpoint. Unfortunately, it was very messy and very unreadable. I mentioned that I would fix it later. Well…it’s now…later (temporal paradox, anybody 🤨?).
If you recall, the output of my POST request looked like this:
JSON is not displaying correctly
Well, the reason why I didn’t originally pipe in the
json_pp command is because this is what happened when I attempted it:
Jefe to the rescue
After reading my newly published article, Jefe suggested I try the
Which, of course, I did. Still no luck:
Andiamo a googliare!
Online search to the rescue
Search online using the keywords “parse error: Invalid numeric literal at,” and you’ll quickly discover that you’re not the only one with this problem.
Five minutes of research revealed a potential culprit. What I was experiencing seemed to be a known issue. For example, a long-standing
jq bug on GitHub details this exact scenario. This doesn't seem to be a
json_pp issue. Instead, the problem is somehow related to the
-i cURLcommand option and
After another few minutes, as luck would have it, I found a Stack Overflow thread discussing the same issue I encountered! After scrolling to the bottom of the thread, I found this golden nugget:
Testing without -i
So, I did just what Mattias and nhs503 suggested. I removed the
-i option (-i, or — include) from my
cURL command, and wouldn't you know? The damn thing works as expected! I tested while piping
json_pp. I also concede that
jq is the prettier of the two; I appreciate the colors (although, admittedly, this would NOT pass any accessibility testing).
The modified commands used:
curl -X POST --user ORDSTEST:password1234 --data-binary "@sportCountryMatrix.sql" -H "Content-Type: application/sql" -k http://localhost:8080/ords/ordstest/_/sql | jq
curl -X POST --user ORDSTEST:password1234 --data-binary "@sportCountryMatrix.sql" -H "Content-Type: application/sql" -k http://localhost:8080/ords/ordstest/_/sql | json_pp
And the results:
And for some final thoughts…
- It turns out it’s NOT ORDS — it’s something to do with an underlying
JSONparser not liking the header info that is coming through
jqwork; they output the information in different order
- The ORDS REST-Enabled SQL Service returns to you not only your results, but the SQL statement initially used (that is cool and I didn’t originally realize or mention this)
And that’s it for this one! I really hope you find this useful. I hope this saves you some time from having to troubleshoot and/or hunt for a fix for this tricky problem. That’s all for now!
And don’t forget to follow, like, subscribe, share, taunt, troll, or stalk me!