We are in need of formatting the JSON file using shell scripting.
INPUT
{
"version": ["sessionrestore",1], "windows": [{"tabs": [{"entries": [{"title": "news.ORF.at","docshellID": 298,"docIdentifier": 10062,"persist": true},{"title": "news.at","docshellID": 288,"docIdentifier": 00062,"persist": false}]}
}
}
Expected Output
{
"version": [
"sessionrestore",1
],
"windows": [
{
"tabs": [
{
"entries": [
{title : news.ORF.at , docshellID : 298, docIdentifier : 10062 ,persist : true},
{title: news.at,docshellID: 288,docIdentifier: 00062,persist: false}
]
}
}
}
Can anyone help us to get the desired output using shell scripting? Please let me know if any additional information required on this
Related
I am using JSON extractor in JMeter. Below is my Response Body. I am using the Json path expression to capture the value, which is working fine.
Apart from the above condition, I need to add one more condition.
If the "travelID" length is equal to 33, then only I need to get the BoundID.
Example : AAA-AB1234-AAABBB-2022-11-10-1111
Total length or count of the above travelID is 33, but sometime I used to get 31,32 also but I need to capture the Bound ID only when the length is 33. Is that feasible ? Please help on the same
PFB sample response body.
{
"data": {
"RenewalDetails": [
{
"ExpiryDetails": {
"duration": "xxxxx",
"destination": "XXX",
"from": "XXX",
"value": 2,
"segments": [
{
"valudeid": "xxx-xx6262-xxxyyy-1111-11-11-1111"
}
]
},
"Itemdetails": [
{
"BoundId": "xxx-1-xxx1-111111111111-1",
"isexpired": true,
"FamilyCode": "PREMIUM",
"availabilityDetails": [
{
"travelID": "AAA-AB1234-AAABBB-2022-11-10-1111",
"quota": "X",
"scale": "XXX",
"class": "X"
}
]
}
]
}
]
},
"warnings": [
{
"code": "xxxx",
"detail": "xxxxxxxx",
"title": "xxxxxxxx"
}
]
}
I don't think it's possible with JSON Extractor, I would rather suggest going for JSR223 PostProcessor and the following Groovy code:
def BoundId = new groovy.json.JsonSlurper().parse(prev.getResponseData())
.data.RenewalDetails[0].Itemdetails.find { itemDetail ->
itemDetail.availabilityDetails[0].travelID.length() == 33
}?.BoundId
vars.put('BoundId', BoundId ?: 'Not Found')
You will be able to refer extracted value as ${BoundId} later on where required.
I am getting the following error in the Google Actions console and can't seem to work out where I'm going wrong. I've tried to use this link for guidance. If remove the "noInputPrompts" section then the response works as expected.Any ideas please?:
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "(expected_inputs[0].input_prompt.no_input_prompts[0]) simpleResponse: Cannot find field." HTTP Status Code: 200.
My response looks like this:
"expectedInputs": [
{
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
],
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "test",
"displayText": "test"
}
}
]
},
"noInputPrompts": [
{
"simpleResponse": {
"textToSpeech": "Test",
"displayText": "Test"
}
}
]
}
}
I am trying to construct a JSON formats follows but running into below error, what is wrong with the below format and how to fix it?
{
project_sha_list: [{
project: project1
sha: sha1
},
{
project: project2
sha: sha2
}
]
train: train1
}
ERROR:-
Error: Parse error on line 1:
{ project_sha_list: [{
--^
Expecting 'STRING', '}', got 'undefined'
JSON keys and string values must be in quotes like below, but if the value is integer,double,long then it should not be enclosed in quotes, and if you have multiple properties each property should end with , except last one
{
"project_sha_list": [
{
"project": "project1",
"sha": "sha1"
},
{
"project": "project2",
"sha": "sha2"
}
],
"train": "train1"
}
Your JSON should be:
{
"project_sha_list": [
{
"project": "project1",
"sha": "sha1"
},
{
"project": "project2",
"sha": "sha2"
}
],
"train": "train1"
}
You can validate it here
you keys and values both should be within "
Try this format:
{
"project_sha_list": [
{
"project": project1,
"sha": sha1
},
{
"project": project2,
"sha": sha2
}
],
"train": train1
}
The correct jain format is:
{
"project_sha_list": [
{ "project": "project1", "sha": "sha1" },
{ "project": "project2", "sha": "sha2" }
],
"train": "train1"
}
I want to set specific parameters for the built-in CFLint rules using CFLint 1.2.3. Unfortunately, there is currently no clear description how to do that.
So I tried to set them in different ways within the configuration having a look at the project test files and the provided JSON schema:
As defined in one of the test files:
{
"rule" : [
{
"name": "VariableNameChecker",
"className": "VariableNameChecker",
"message": [
{
"code": "VAR_TOO_SHORT",
"severity": "INFO",
"messageText": "Variable ${variable} SHORTER THAN ${MinLength}!"
}
],
"parameter": [
{
"name": "MinLength",
"value": "5"
}
]
}
],
"inheritParent" : true
}
Within the rule object:
{
"rule": [ ],
"excludes": [ ],
"includes": [
{
"code": "VAR_TOO_SHORT",
{
"parameter": {
"MinLength": "5"
}
}
}
],
"inheritParent": false
}
As separate global property:
{
"rule": [ ],
"excludes": [ ],
"includes": [
{
"code": "VAR_TOO_SHORT",
}
],
"parameter": {
"MinLength": "5"
}
"inheritParent": false
}
I also tried different naming conventions as parameter name like VariableNameChecker.MinLength and also writing parameters instead of parameter, though without luck.
What is the correct syntax to specify the parameters?
The only ways to override a plugin param prior to CFLint 1.3.0 are
(1) replace the cflint.definition.json file with your own
(2) set a system property in the form ClassName DOT parameter. for example:
java -DVariableNameChecker.MinLength=5 cflint-1.2.3-all.jar -file
In CFLint 1.3.0 the following will work:
{
"parameters" : {
"VariableNameChecker.MinLength": "5"
}
}
I am using lintr in Sublime 3 via SublimeLinter 3 and the SublimeLinter-contrib-lintr plugin. On the lintr README.md file there is a short mention on how to configure what linters should be used:
{
"user": {
"linters": {
"r": {
"linters": "with_defaults(line_length_linter(120))"
}
}
}
}
However, I am using it in conjunction with SublimeLinter-contrib-lintr and I can't get it to work. My SublimeLinter.sublime-settings file looks like this:
{
"user": {
"debug": true,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"lintr": {
"#disable": false,
"args": [],
"cache": "TRUE",
"excludes": [],
"linters": "default_linters"
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": [
"C:/Program Files/R/R-3.3.3/bin/x64"
]
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"r extended": "r"
},
"warning_color": "DDB700",
"wrap_find": true
}
}
The lintr package has a bunch of linters (see this link). What I would live to achieve is to discard some of them (i.e., not use, for instance, assignment_linter). Do you have any idea how to achieve this? It should be possible, right?
Edit 1:
I noticed that by changing "linters": "default_linters" to "linters": "assignment_linter", only the errors falling under assignment_linter will be picked. I tried to expand it using an array, but it doesn't work:
...
"lintr": {
"#disable": false,
"args": [],
"cache": "TRUE",
"excludes": [],
"linters": [
"assignment_linter",
"object_name_linter"
]
}
...
Inside the Sublime 3 console, the message error message with this attempt is: Error: unexpected '[' in "lint(cache = TRUE, commandArgs(TRUE), [".
Edit 2: possible solution
Looking at with_defaults inside the lintr package I found two ways of choosing only the linters I am interested in. Assuming that I only want assignment_linter and no_tab_linter, the configuration is:
"linters": "default_linters[c('assignment_linter', 'no_tab_linter')]" or
"linters": "with_defaults(assignment_linter, no_tab_linter, default = NULL)"
It works, but are there other less error-prone approaches? With this approach if I want to discard just one linter I have to list all the others.
Regarding your question for "Edit 2", you can discard a single linter as follows:
{
"user": {
"linters": {
"r": {
"linters": "with_defaults(some_default_linter = NULL)"
}
}
}
}
... where some_default_linter is the name of a linter from the list lintr::default_linters.