Running Go from the command line nested JSON - unix

I can think of workarounds on how to get this working however I'm interested in finding out if there's a solution to this specific problem.
I've got a go program which requires a json string arguement:
go run main.go "{ \"field\" : \"value\" }"
No problems so far. However, am I able to run from the command line if one of the json values is another json string?
go run main.go "{ \"json-string\" : \"{\"nestedfield\" : \"nestedvalue\"}\" }"
It would seem that adding escape characters incorrectly matches up the opening and closing quotes. Am I minuderstanding how this is done or is it (and this is the side I'm coming down on) simply not possible?
To reiterate, this is a question that has piqued my curiosity - I'm aware of alternative approaches - I'm hoping for input related to this specific problem.

Why don't you just put your json config to the file and provide config file name to your application using flag package

Based on the feedback from wiredeye I went down the argument route instead. I've modified the program to run on:
go run main.go field:value field2:value json-string:"{\"nestedfield\":nestedvalue}"
I can then iterate over the os.Args and get the nested json within my program. I'm not using flags directly as I don't know the amount of inputs into the program which would have required me to use duplicate flags (not supported) or parse the flag to a collection (doesn't seem to be supported).
Thanks wiredeye

Related

Vscode settings problems

So I'm editing my settings in JSON and it all works well but this error keeps popping up:
"Expected comma jsonc(514)"
This is my code:
"css.lint.emptyRules": "ignore",
This is the whole json file just in case:
Whole Json file
You are missing a comma after the "gitlens.advanced.messages" object and before "css.lint.emptyRules": "ignore". That should solve your issue, also I highly advise you to take a look here JSON Syntax

Unrecognized escape characters in bindings with BizTalk Deployment Framework

I'm using BTDF and the settingfilegenerator to dynamically configure the bindings. My first binding was a SQL binding and it worked fine. However, most of my binding settings are UNC paths and I'm getting errors when trying to apply the settings. I have tried about every combination of quotes and doubling the backslashes to try to handle this but nothing is working. Surprisingly I haven't been able to find anyone else with the same issue. Any ideas?
parsing "\Myserver\Myshare\Folder\SubFolder\inbound\Enroll\%SourceFileName%.834" - Unrecognized escape sequence \i.
Thanks for the comments. It made me look into where it was actually failing instead of the error message. It appears to be an issue with the the install-biztalkapplication.ps1 script. I'm not sure the origin and if there were any changes made to this script. I commented out this block (full block not shown) and this last line is what is causing the error. There seem to be several versions of this file available. I'll do some additional research and provide an update.
get-content -path "$btdfdeploysettingsfile" | foreach-object {
$line = $_
$hashconfig.getenumerator() | foreach-object {
Thanks for everyone's help to point me in the right direction. In the end the issue was in the install-biztalkapplication.ps1 and not with BTDF directly. I removed the bad lines and the replacement is working now.

Using U-SQL MultiLevelJsonExtractor gives Error: Path returned multiple tokens

I am using the MultiLevelJsonExtractor forked on Git by kotvisbj, When I put a Path that contains an array (body.header.items[*] or body.header.items) into the JsonPaths parameter string, I get a "Error: Path returned multiple tokens". Is there a way to extract the paths in code so I can get an array like when using the Root? I tried to explain this the best way I could, I don't have excellent c# skills, it's been a few years.
I think it would be best to ask the owner of the branch to see if he can advise you. I assume that his code expects a single token only and not an array of tokens.
You can probably achieve what you need by using code similar to this: U-SQL - Extract data from json-array

how to give the String input with Special characters in Xpath using R selenium

result <- z$findElement(using = 'xpath',"//*[contains(text(),'the deal” of hosting major sporting')]")
In above command the reference String have special character the deal” so ,R gave the Error as
Error: Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
but the reference element found in the particular URL.
I think the issue is with your syntax of 'contains' and the use of double quotes.
Check here below the correct syntax:
[text()[contains(.,'the deal of hosting major sporting')]]
also the error you are getting means that the element wasn't present at the time of checking. This can occur for a number of reasons.Two of the most common are: 1) you checked too early (i.e. a wait should be introduced instead of a delay).
wait.until(ExpectedConditions.elementToBeClickable(By.id<locator>));
2) Your xpath is wrong (most likely). Noticed you are using //* which means any node so as far as we know, you could be pointing to multiple elements. If you want a more specific xpath answer please post a screenshot with the html code of element you are trying to locate. But I'll take an educated guess on the below:
(your way improved without the ")
findElement(using = 'xpath',"//*[contains(text(),'the deal of hosting major sporting')]");
and if that does not work, go for this:
findElement(using = 'xpath',"//*[text()[contains(.,'the deal of hosting major sporting')]]");
Best of luck!

Simplest way to validate non-library module

What is the simplest way to validate there are no syntax errors in an XQuery file? I want to test a number of xquery files as a part of routine testing to verify that no bad files exist with simple syntax errors. Generally for library modules I import the library module and that is enough to validate syntax of the file.
BaseX has an option RUNQUERY that can be used to disable query execution, so it only gets parsed. For using the command line, use the -R off flag.
The query can be passed as string, here I'm using the very simple query 1+1, which is totally valid and will not return any output, but a return value of 0.
basex -R off "1+1"
Passing an invalid query will return a syntax error message, and a non-zero return code.
basex -R off "1foo"
Stopped at [snip], 1/2:
[XPST0003] Expecting separator after number.
I guess there will be similar options for other XQuery implementations, but they're not standardized, so you'll have to look them up in the individual manuals.

Resources