json to query

Anyone have a simple example of using wirebox to validate/convert some JSON to a query?

I’m trying to use this and I can’t figure out what I need to inject.


is that exposed as a plugin?

it looks like its an interface to serializeJSON(), isJSON(), etc.

I ended up just deserializing using CF’s DeserializeJSON function. I’d like to know if anyone thoughts around the right or wrong of doing this verus what Coldbox has?

My source JSON is coming via an API and it seems to have some characters that appear as carriage returns in it that are causing it to be invalid. I’ve tried JSStringFormat and even doing a replace on carriage returns using asc(13) and my JSON still seems to be invalid.

Anyone have a standard way of ‘fixing’ JSON that may contain such items?

what does isJSON() tell you?

isJSON() is reporting false. If I copy and paste the JSON into http://jsonlint.com/ it shows me where the issue is. The problem is in the description where is has an unneeded carriage return. The problem is no matter what I do this JSON I can’t remove it and I don’t control the system that the JSON is coming from to fix the problem at the source.

I’ve tried stuff like




with no success. I can’t be the first person so see bad JSON and have to deal with it.

Here is a clip of my JSON.

“bugs”: [
“id”: 694301000000069000,
“key”: “16”,
“project”: {
“id”: 694301000000014300
“flag”: “Internal”,
“title”: “Enrollment issue with programs that refugee enrollment programs”,
“description”: "need a design change to handle enrollment by refugee
“reporter_id”: “35597854”,
“reported_person”: “Jonathan Perret”,
“created_time”: “06-01-2014”,
“created_time_format”: “06-01-2014 12:59 AM”,
“created_time_long”: 1401631183000,
“assignee_name”: “Not Assigned”,
“classification”: {
“id”: 694301000000016000,
“type”: “OtherBug”
“severity”: {
“id”: 694301000000007000,
“type”: “Major”
“status”: {
“id”: 694301000000007000,
“type”: “Closed”
“closed”: true,
“reproducible”: {
“id”: 694301000000016000,
“type”: “Always”
“module”: {
“id”: 694301000000016100,
“name”: “RMS”
“link”: {
“self”: {
“url”: “https://projectsapi.zoho.com/restapi/portal/37158570/projects/694301000000014351/bugs/694301000000069001/
“timesheet”: {
“url”: “https://projectsapi.zoho.com/restapi/portal/37158570/projects/694301000000014351/bugs/694301000000069001/logs/

try chr(13)

also http://help.adobe.com/livedocs/coldfusion/8/htmldocs/help.html?content=functions_s_14.html

Already tried stripcr with no luck. I clearly should have been using chr.

Interesting thing is if I do a


The first find does indeed find a CR and the replace does replace any it finds because the second find returns 0. But when I dump out the JSON I can clearly see it in the same place that JSONLint is complaining about.

try chr(13)&chr(10)

replaced chr(10) and still have issue.

or try rereplace(“str”,"\n",“all”,“all”) or rereplace(“str”,"\r",“all”,“all”)

oops - you know what I mean

I’ve tried it all.

writeoutput(isJSON(LOCAL.test4)); // result is no
writeoutput(LOCAL.test4); //I can still see the same result in the JSON


no difference


if I do a JSStringFormat on the JSON, I see the \n where the problem is. When I do a replace \n before I run it through JSStringFormat I don’t see the \n but either way problem still exists., So it’s something else blowing up the JSON.

upload the json file somewhere or point to the url where you’re getting it from.

Jonathan posted the json earlier in the thread, but it got a little garbled. Here is the pastbin: http://pastebin.com/8ZFgSvsM
You can see the line break on line# 11-12

Have you tried

LOCAL.test3=replace(LOCAL.test2,char(13) & chr(10),’’,‘ALL’);


Again, this works for me, so I’m not sure what the issue is:

LOCAL.httpService = new http();
LOCAL.result = LOCAL.httpService.send().getPrefix();

Must be some in my version of CF because I get, JSON parsing failure at character 7721:‘J’ . I copied your code to make 100% sure.