Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda