Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
Trying to selectively forgo quotes when serializing a structure to JSON

I am querying SQL and using that and ColdFusion [2018] to build a struct containing a JS schema. After building the structure, I use serializeJSON and pass it to my JS [side note: Kendo UI]. Below is that resultant JSON that has been getting generated [approx]:

const dataModel = { id:"ID",
    "fields": {
        REPORTTITLE    : {
            nullable       : false,
            "hidden"       : false,
            type           : "string",
            template       : "reportTitleTemplate",
            filterable     : "{delay : 1500}" 
        },
        ISACTIVE       : {
            nullable       : false,
            "hidden"       : false,
            type           : "boolean",
            template       : "booleanTemplate",
            filterable     : true  
        },
        COLUMNGROUPING : {
            nullable       : false,
            "hidden"       : false,
            type           : "string"...and so on... 
        }
    }
};

The obvious problem I'm running into is two fold. 1st- For some reason the key hidden, and only hidden, is being quoted. It is possible that this my fault due to some random 'fix' buried deep in a service, but I doubt it. I can resolve this, I suppose. 2nd-[and this is my main concern] I need a way to effectively signal that values for the key Template do not get quoted. The same goes for filterable when it is itself a struct. I need the above to output as below instead:

const dataModel = { id:"ID",
    "fields": {
        REPORTTITLE    : {
            nullable       : false,
            hidden         : false,
            type           : "string",
            template       : reportTitleTemplate,
            filterable     : {delay : 1500} 
        },
        ISACTIVE       : {
            nullable       : false,
            hidden         : false,
            type           : "boolean",
            template       : booleanTemplate,
            filterable     : true  
        },
        COLUMNGROUPING : {
            nullable       : false,
            hidden         : false,
            type           : "string"...and so on... 
        }
    }
};

I abhor the thought of using ReReplace or the like. Differentiating filterable values of true/false versus structs, I can work all of that out, "hidden" would be light enough if I need to do a replace on that alone. I am just hoping that someone has run across this situation before and discovered something a little more elegant than a brute force replace for the template and filterable keys [or whatever key/value pair, obviously].
These reports do get very massive and I'm on a bit of a cycles/request vigilance kick... Any input is appreciated, I've found practically another on this topic.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda