
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
JSON Configuration Manager
Welcome to JSON Configuration Manager - created and maintained by Tom Hauri.
Overview
JSON Configuration Manager provides an easy way to manage and consume complex JSON structures with a built in inheritance features that allows you to reuse common JSON structures.
<Picture 1: parent demo data record>
Disclaimer
JSON Configuration Manager is NOT an officially supported ServiceNow product. JSON Configuration Manager does NOT come with any kind of warranty. If you use it, you own it!
System Requirements
- Utah or later
- Access to https://github.com/haurit/now-jsoncfgmanager
License
Copyright 2022-2023 by Tom Hauri
Licensed under the Apache License, Version 2.0 (the "License")
You may not use JSON Configuration Manager except in compliance with the License.
You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Release Notes
1.0.0 - 12.2022
- Initial Release
1.0.5 - 11.2023
- Added administration menues
- Added manual page
- Added ATF Tests
- Changed getValue to return the substitute value if value is gs.nil()
1.0.6 - 04.2024
-
Inheriting JSON Configurations with active root flag will merge on same level
Problem Statement
Sustainable solutions are configurable so that you don't have to change the code to adapt to changing user requirements.
Handling this data can be done in various ways, the table below shows why I choose JSON most of the time:
How / Rating | Hardcoded | System Properties | JSON | User Interface |
---|---|---|---|---|
Usability | LOW | MIDDLE | MIDDLE | VERY HIGH |
Maintainability | VERY LOW | HIGH | HIGH | HIGH |
Scalability | LOW | LOW | VERY HIGH | LOW |
Upgradability | NO IMPACT | NO IMPACT | NO IMPACT | NO IMPACT |
Performance | NO IMPACT | NO IMPACT | NO IMPACT | NO IMPACT |
Security | NO IMPACT | NO IMPACT | NO IMPACT | NO IMPACT |
Flexibility | LOW | MIDDLE | VERY HIGH | LOW |
Effort to build | LOW | MIDDLE | LOW | VERY HIGH |
While JSON is very strong when it comes to Scalability, Flexibility and Effort to build its weakness is that it does not score that well in terms of Usability.
The JSON Configuration Manager aims to solve that by adding a user interface to manage the JSONs and template functionality to ensure you can reuse JSON templates to avoid data duplications. It also provides an API to consume the data.
Installation
- Create an account on GitHub - if not done already.
- Create a personal access token for your GitHub account.
- Add credentials to access GitHub - use "Basic Auth".
- Fork the repository https://github.com/haurit/now-jsoncfgmanager.
- Go to Studio and import the JSON Configuration Manager application from source control.
- Verify that the demo data has been loaded an updated correctly. If the attachment and relationship related lists are missing run the fix script UpdateDemoData again.
ATF Test
To successfully pass the ATF tests it might be neccesary to add the common client errors to the whitelist.
Usage
There are two different steps in using the JSON Configuration Manager application. First you define the JSON and then you use it in your applications.
JSON Definition
Navigate to the JSON Configuration menu or use the x_snc_json_cfg_mgr_json_configuration.list shortcut.
For the top level JSON (e.g. the one you will call in your script) you must ensure the "Root" is set to "true". Then define your main JSON structure in the variable (ensure to keep the initial script intact and don't change the variable name).
If required you can create new JSON Configurations as children (e.g. set "Root" to "false"). In order to use such a building block use the "{{name_of_the_json_config}}" notation. To reuse the same child JSON Configuration multiple times you can separate the name with a pipe "|" character {{name_of_the_object_key|name_of_the_json_config}}. The last pipe will separate the name form the lookup value used to find the child JSON Configuration. You can also nest children in children if required. Please note that arrays are NOT merged.
Once you save your JSON Configuration "Root" an attachment with the calculated "JSON" is added. Please note that currently the attachment is only recalculated when you make a modification to the "Root" and save it. Changing the children will not automatically update the attachment.
Please have a look at the demo data demo_parent_1 for inspiration on how this works in real. To do the first steps just copy the demo data or start with a small root configuration and expand step by step.
Usage in scripts
To retrieve the JSON use the following notation:
var _getCfg = new x_snc_json_cfg_mgr.getCfg(sConfigName); // initiate by name (other options are to pass in the sys_id or the glide record of a json configuration file or any valid json) var oObj = _getCfg.getConfig(); // will return the whole JSON var sValue = _getCfg.getValue('key1/key2/key3', 'value_if_empty', {'object to use'}); // sConfigPath (path to find object value), if empty 'value_if_empty' will be undefined, if empty {'object to use'} will be the object defined in the class initialization)
- 1,158 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.