VB.NET How to access object (deserialized from JSON) - vb.net

If someone would be so kind as to help me get the highlighted line in to a variable, I would be very grateful.
I tried the following:
Dim Fromid = FBrequest.data(0)(3)("from")(2)
but it said the key was not present in the array.
Image is at imageshack.us
/img33/1491/wtfjsondeserialized.png

I would suggest doing a foreach to see what keys are present in your array. Example:
For Each entry As String In FBrequest.data(0)(3)
Console.WriteLine(entry)
Assuming that the "from" is the key that is missing. Additionally, I would also suggestion setting a breakpoint on this line and adding a watch statement. Inspect your FBRequest.data variable to see what the contents are.

Related

watson conversation check entity exists

I want to check if an entity is part of the users input.
Example:
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
As you can see by this example, the value of the entity#PRODUKT_INTENT_STOP_LIST
is a variable. I put this at a condition for a node, but this is not working.
If I use a hardcoded string instead of the variable it is working fine.
entities['#PRODUKT_INTENT_STOP_LIST']?.contains('Chart') works fine
but setting $variables.tmpEntity to 'Chart' a and then ask for
entities['#PRODUKT_INTENT_STOP_LIST']?.contains($variables.tmpEntity)
is not working.
Can someone tells me what's wrong here?
Still trying to understand what you are trying to do.But if you want to check whether an entity exist in your input or not you can do it by applying condition on size of that entity.
"context":{
"size":"<?#Entity.size()?>"
}
now if size is equals to 0 then entity does not exist.
I know this is a longer way but it also tells you how many times does that entity exist in your input.
Hi I used the wrong statement.
This statement should work:
entities[PRODUKT_INTENT_STOP_LIST]?.get($variables.countEntity).value==$variables.$variables.tmpEntity
$variables.countEntity : counter to iterate thru entity array #PRODUKT_INTENT_STOP_LIST to check if an entity value is equal $variables.tmpEntity
Regards

ListObjects.Add.QueryTable Source Array String

I will provide some context before I ask my question.
I am attempting to query an SQL Server and create a table within Excel from the data. Because I am not familiar with how to accomplish this in VBA I recorded by using Data -> Get External Data -> From Other Sources -> Microsoft Query. In the dialog box that appears, I chose a .DSN file provided to me by someone else. I then used the Microsoft Query interface to structure the query and import the data onto a worksheet.
The code in the recorded macro looked something like this. I will use generic terms instead of the actual code.
With Sheet2.ListObjects.Add(SourceType:= 0, Source:=Array _
(Array("ODBC;DRIVER=SQL Server;SERVER=ServerName;UID=userid;Trusted_Connection=Yes;APP=Microsoft Windows Operating System;WSID=SomeString"), _
Array("A;DATABASE=DatabaseName")), Destination:=Range ("Sheet2!$A$1")).QueryTable
I know this is not formatted ideally, which is part of my question below.
https://msdn.microsoft.com/en-us/library/bb211863(v=office.12).aspx
From the above article, I know that SourceType:= 0 is an xlSrcExternal, or an external data source. This makes sense to me.
My confusion begins to arise when I get to the Source component of the Add method. From the provided article, "When SourceType = xlSrcExternal, an array of String values specifying a connection to the source, containing the following elements:
•0 - URL to SharePoint site
•1 - ListName
•2 - ViewGUID
So to begin with, what exactly is meant by "an array of String values", as the code from the recorded macro does not appear to correspond to what I thought was an array. I know that normally an array is declared something like this Array("string1", "string2", etc.). Or is the array recorded simply an array of one value? In other words Array("string1"). Does anyone know the purpose of passing an "array of string values" as opposed to just passing a string?
Also does anyone know the nuances of why the recorded macro has this particular formatting/syntax? In other words, why does it appear to have this syntax Array(Array("string1"),_ (new line) Array("string2"))? Why not just Array ("string1")? Does it have something to do with the second line being too long?
I have several more questions related to this topic, but this seemed like a good place to start..
Thank you all for any help given.

Access Javascript Array with numeric key

I tried to access the following value in an multidimensional array:
var temp = allSliderData[i]['slider_full'][j].path;
and it works fine, but the following not
var temp2 = allSliderData[i]['slider_thumbs'][j].285x255;
with the answer
"SyntaxError: identifier starts immediately after numeric literal"
I now tried escapings, array functions .. this message is good known in stackoverflow .. but still no luck.
Could anybody help out?
THANKS!!
Something like that won't work. You can't have a property named "2" there. What exactly do you want to do?

How to use Get command in Monkey talk?

Does anybody know how to use the Get command in monkey talk?
In monkey talk guide only the command is written but no syntax is present.
Here is an example for you,
var x = app.label("label1").get("x","value")
Above line will get the value of label1 and store it in variable x. You can change the second parameter "value" to ".text" or ".size" depending on your needs
since the question is not marked Answered and For the future reference i am answering this.
‘GET’ ACTION RETRIEVES COMPONENT PROPERTY VALUES
Syntax:
ComponenType MonkeyId Get varName propName
Works like an assignment statement (varName= propName)
The default property is “value”
// Get label value currently displayed
Label lastname Get name
// Enter name into input field
Input query EnterText ${name}
// Get the first table item
Table countries Get country items1
// Enter into input field
Input * EnterText ${country}
you can refer this document here, thanqs
I will try to explain using example. Suppose there is a ListView(Table) and you want to scroll till its last item.
//Define a variable
Vars * Define row
//Store size of list in variable row using Get. Check use of "Get" here
Table * Get row size %thinktime=20000
//Now stored variable can be used as per need. here I am using for scrolling
Table * ScrollToRow ${row} %thinktime=2000
Hope it helps you !!

Newbie issue with LINQ in vb.net

Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value
Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
WHERE....
DataCache.Tags is an array of custom objects
strtagname = "brazil"
and brazil is definitely a tag name stored within one of the custom objects in the array.
However the function continually returns false.
Can someone confirm to me that the above should or should not work.
and if it wont work can someone tell me the best way to test if any of the objects in the array contain a property with a specific value.
I suppose in summary I am looking for the equivalent of a SQL EXISTS statement.
Many thanks in hope.
Your code is currently checking whether the count is exactly one.
The equivalent of EXISTS in LINQ is Any. You want something like:
Return DataCache.Tags.Any(Function(tag) tag.FldTag = strtagname)
(Miraculously it looks like that syntax may be about right... it looks like the docs examples...)
Many Thanks for the response.
Your code did not work. Then I realised that I was comparing to an array value so it would be case sensitive.
However glad I asked the question, as I found a better way than mine.
Many thanks again !