Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
I have this JSON
[
["pimenta & guedes", "Rodrigo"],
["24", "29"],
["32", "10"],
["77", "5"],
["Cartao", ""]
]
How can I get the second element, Rodrigo?
I am using Robot Framework and I have tried this command :
${FILECONTENT}= Get File c:/aa/webdemo-master2/login_tests/sample.txt
#Log to console ${FILECONTENT}
${JSON}= evaluate json.loads($FILECONTENT) json
Log to console ${JSON}
Log Hello, my name is ${JSON[0]}
But the result is (Hello, my name is ['pimenta & guedes', 'Rodrigo'])
But I would like to get (Hello, my name is Rodrigo)
Thanks in advance.
Your JSON is a two dimensional array. ${JSON[0][1]} should give you what you are looking for.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I've got this example:
try {
images = this.getFinderFiles(path);
} catch (DirectoryNotFoundException exception) {
return [];
}
There is something wrong with this code?
I would recommend not to use exception handling for expected error situations. Exception handling takes time, stack unwinding has to be done.
In your case, if you usually can expect that 'path' usually exists and therefore the method can return a decent result - so you do not expect that 'this.getFinderFiles' fails - then it is fine to use exceptions here. But otherwise test the path for existence first before calling 'getFinderFiles'. That should be faster and for my taste more readable.
Btw. can you check the existence of 'path' within 'getFinderFiles' and eventually return '[]' already there?
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
It's my first day working with JSON.
For Example, how can I filter the Title and IsExploitable out of this script?
{
"Title": "hello world",
"ManualId": ten,
"IsExploitable": false,
"IsTicketAssigned": false
}
The final result should display the Title: Hello World and the Answer of IsExploitable which in this case is false.
I want to do this in bash.
Using jq:
$ jq '{Title, IsExploitable}' file
Output:
{
"Title": "hello world",
"IsExploitable": false
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I've got an assignment that is due tomorrow..
I don't want the entire solution, there's just a part of the program that i dont understand.
It's highlighted in the image below:
(I dont know what "save the values into the parameters of a method" means)
As you can see the type of the parameters is double& which means you are storing the values within the arguments you are sending. e.g, if you have 3 doubles a,b & c, when you call getAll(a,b,c) the result should be stored in them.
You can find more detailed explanation about &(reference) operator in
What does '&' do in a C++ declaration? .
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
guys I have this code which is written in Json as it is supposed to generate a document with repeated objects _id and items
I have used repeat function and passed a list to it with these objects , also i do not have clear understanding about what objectid do
'repeat(21, 0)': [ {_id :objectId()}
, items : items()} ]
but it is giving me this error SyntaxError: Unexpected token :
I am using this site https://next.json-generator.com
solved guys , you can find the code below
[
{
'repeat(21, 0)': {
_id: '{{objectId()}}',
items: '{{company().toUpperCase()}}',
}
}
]
it is a list with an object which contain a function repeating its containing objects
, please correct me if i am wrong or give more clarification.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have the next JSON object
console.log:
Object {0: "/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg",
1: "/files/ff/54/e3/17/medium/ff54e317d47631661eafeec6638ec530.jpeg",
2: "/files/b3/27/63/17/medium/b3276317020322ef77ac39447075286e.jpeg"}
And I need to remove element from this object by this string:
/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg
I read a plenty of solutions for this question but all of them was about object with not numeric indexes. I use jQuery for it.
Please help me with function for my trouble. Thanks in advance.
Iterate through the object to find the value and delete the key once found:
// Assuming your object is called "foo":
for ( var k in foo ) {
if (foo.hasOwnProperty(k)) {
if (foo[k] === '/files/f6/bd/05/a9/medium/f6bd05a970c63b77eae164a607441818.jpeg') {
delete foo[k];
}
}
}
console.log(foo);