This code snippet will help you filter out dataStoreLogFileSize greater than 1GB and with a production dataStoreLogLevel.
const jsonData = {
"web-app": {
servlet: [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f19a829cb1819e939e89df929e9c">[email protected]</a>",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
"configGlossary:staticPath": "/content/static",
templateProcessorClass: "org.cofax.WysiwygTemplate",
templateLoaderClass: "org.cofax.FilesTemplateLoader",
templatePath: "templates",
templateOverridePath: "",
defaultListTemplate: "listTemplate.htm",
defaultFileTemplate: "articleTemplate.htm",
useJSP: false,
jspListTemplate: "listTemplate.jsp",
jspFileTemplate: "articleTemplate.jsp",
searchEngineListTemplate: "forSearchEnginesList.htm",
searchEngineFileTemplate: "forSearchEngines.htm",
searchEngineRobotsDb: "WEB-INF/robots.db",
useDataStore: true,
dataStoreClass: "org.cofax.SqlDataStore",
redirectionClass: "org.cofax.SqlRedirection",
dataStoreName: "cofax",
dataStoreDriver: "com.microsoft.jdbc.sqlserver.SQLServerDriver",
dataStoreUrl:
"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
dataStoreUser: "sa",
dataStorePassword: "dataStoreTestQuery",
dataStoreTestQuery: "SET NOCOUNT ON;select test='test';",
dataStoreLogFile: "/usr/local/tomcat/logs/datastore.log",
dataStoreInitConns: 10,
dataStoreLogFileSize: "1GB",
dataStoreMaxConns: 100,
dataStoreConnUsageLimit: 100,
dataStoreLogLevel: "production",
maxUrlLength: 500
}
},
{
"servlet-name": "cofaxTools",
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
"init-param": {
templatePath: "toolstemplates/",
log: 1,
logLocation: "/usr/local/tomcat/logs/CofaxTools.log",
logMaxSize: "",
dataLog: 1,
dataLogLocation: "/usr/local/tomcat/logs/dataLog.log",
dataLogMaxSize: "",
removePageCache: "/content/admin/remove?cache=pages&id=",
removeTemplateCache: "/content/admin/remove?cache=templates&id=",
fileTransferFolder:
"/usr/local/tomcat/webapps/content/fileTransferFolder",
lookInContext: 1,
adminGroupID: 4,
betaServer: true,
dataStoreInitConns: 10,
dataStoreLogFileSize: "0.5GB",
dataStoreMaxConns: 100,
dataStoreConnUsageLimit: 100,
dataStoreLogLevel: "test",
maxUrlLength: 500
}
}
],
"servlet-mapping": {
cofaxCDS: "/",
cofaxEmail: "/cofaxutil/aemail/*",
cofaxAdmin: "/admin/*",
fileServlet: "/static/*",
cofaxTools: "/tools/*"
},
taglib: {
"taglib-uri": "cofax.tld",
"taglib-location": "/WEB-INF/tlds/cofax.tld"
}
}
};
// Filter the JSON data based on conditions
const filteredData = jsonData['web-app'].servlet.filter((s) => {
// Extract the size from dataStoreLogFileSize
const size = s['init-param'].dataStoreLogFileSize.replace(/[^0-9\.]+/g, '');
// Check if size is greater than or equal to 1 and has 'production' log level
return +size >= 1 && s['init-param'].dataStoreLogLevel === 'production';
});
console.log(filteredData);