Javascript - Accessing Elements Of JSON Object Without Knowing The Key Names

Feb 25, 2011

Here's my json:

{"d":{"key1":"value1",
"key2":"value2"}}

Is there any way of accessing the keys and values (in javascript) in this array without knowing what the keys are?

The reason my json is structured like this is that the webmethod that I'm calling via jquery is returning a dictionary. If it's impossible to work with the above, what do I need to change about the way I'm returning the data?

Here's an outline of my webmethod:

<WebMethod()> _
Public Function Foo(ByVal Input As String) As Dictionary(Of String, String)
Dim Results As New Dictionary(Of String, String)

[Code]....

View 2 Replies


ADVERTISEMENT

Javascript - Create A Json Object In 2005?

Sep 8, 2009

I want to create a json object in vb.net to send the response back javascript function to do something?

View 2 Replies

VS 2008 Accessing A DLL Library Without Knowing It?

Feb 22, 2011

Basically I am creating a Windows Service as an 'updater' program to update all my software packages. Whats going to happen is every piece of my software that is installed in its program folder will have an Update.dll this DLL will be a library to do with the update of the software.

There will also be a database in the Updater program folder which will contain a list of all my installed software. So when the service starts it will open my 'database' which will load the paths to all my installed software to a string array. Each path in the string array will have a Update.dll in the folder.

What I need to do then is is in turn call a routine called StartUpdate() from each of those Update.dll which will then do all the work. So the service itself is fairly basic and doesn't really do much I just need to figure out how to access DLL's when I don't actually know what ones will be there while programming, Reason I am doing it this way is to support my future software programmes without having to update the updater.

View 3 Replies

Deserializing JSON Into Byrefrence ParametrizedConstructor Object With Json?

Nov 12, 2010

Below is my JSON formated String

{"AliasName": "ysiCountryInfo", "DataClass": {"Description":"United States 111","Code":"usa","WriteOffTaxPointAdjustment":0,"IndexationRounding":6}}
I would like to deserialize object into below class

[code].....

View 1 Replies

VS 2008 - Accessing File Path Without Knowing Full Name

Jul 16, 2010

I need to access a file path, but a part of the path is different on each PC. Mozilla creates a random profile name for each PC it is installed on. I can get most of the path through environment variables. I need to access the files inside of the default profile, but can't since I'm not sure how to access it.

Here's an example of the file path:
'C:Users\%USERPROFILE%AppDataRoamingMozillaFirefoxProfilesxxxxxxxx.default'
The only thing that stays the same with the profile name, is the '.default' part.

View 4 Replies

Convert JSON String To JSON Object?

Jan 18, 2012

I have a JSON response from a web service that I need to be converted to an object then to an array. My response is similar to the one below:

{"status":{"error":"NO","code":"200","description":"none","message":"Request ok"},"geolocation":{"lat":"38.89515","lng":"-77.0310"},"stations":[{"country":"United States","regPrice":"0.00","midPrice":"0.00","prePrice":"0.00","streetAddress":"1401, I St[code]....

I am doing this is VB.NET within a console for now. Basically I am trying to create a simple way to test my API calls and output the information. What I am trying to accomplish is having to loop through the JSON array and list the stations.

View 3 Replies

Sql - Call Stored Function Without Knowing The Parameter Names?

Dec 13, 2011

how to call a stored function in oracle through vb.net.From vb.net should i able to pass the values to arguments of that function without knowing the parameter names?Example: I have a function,Create or Repalce Function Func_Name(param1 Varchar2,param2 varchar2)

Inorder to call this function through vb.net, we need to give

parameterargs.paramtername="param1"

Is there anyway so that i cannot use the parameter name and call the function

View 3 Replies

Parse And Extract Specific Elements Out Of A JSON?

May 9, 2011

how to parse and extract specific elements out of a JSON that I obtain from a web source. Using Visual Studio 2010 and VB. I can get the JSON but I haven't been able to find any examples or tutorials regarding parsing the data, locating specific elements and their associated data.

View 1 Replies

Javascript - .Net Json Serialization Format?

May 16, 2012

I was hoping someone may be able to point me in the right direction in regards to the format of a Json.I've never really worked with Json's and Serialization before so it's all a little new.I need to return a Json from .Net in the following format.[[Date.UTC(2011,12,14,8), 8], [Date.UTC(2011,12,14,9), 1]]

I'm almost there but am struggling with the format of my string, as by default the string is quoted. This is what I have:

[Code]...

View 2 Replies

Javascript - Return JSON From ASP.NET .asmx?

Nov 5, 2009

I have the following test method:Imports System.Web

Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _

[Code]...

Even with the ResponseFormat attribute added the response is still being returned as XML rather than JSON.

View 6 Replies

JavaScript Serialize Array To JSON?

Mar 28, 2011

I have "Form Designer" web application, in which I need to post the controls of the new form to an ASP.Net page to insert to DB, each time I create form control. I push it into two dimensional array, when user click save, this array will be serialized and sent to Server Page using Ajax.

Array string After Serialization Looks Like :
[
[

[code].....

View 2 Replies

Javascript - Pass JSON File From ASP.NET To JQuery?

Feb 27, 2012

my problem is that my company does not want to serve up the .json MIME type, so I have to use ASP.NET to fetch the JSON file from the file server. Currently I have jQuery that does a getJSON and traverses the JSON object to build certain elements of the page. Is there a way I can use ASP.NET (VB) to give the object to my jQuery script after I fetch it?

View 1 Replies

Javascript - JSON Array Type Resolution In ASP.Net Webservices?

Jan 6, 2011

I have worked out how to pass my custom objects into ASP.Net json webservices. Works a charm. Problem I am having is passing in straight arrays of my custom objects or alternatively passing in arrays that are parameters of my custom objects. So for example...

Public Class WebService1
Inherits System.Web.Services.WebService
<WebMethod()> _

[code]....

Fails with error: The value "System.Collections.Generic.Dictionary`2[System.String,System.Object]" is not of type "WebApplication1.WebService1+Person" and cannot be used in this generic collection. Parameter name: value

So how do I explain to ASP.net that it is infact an array of Person? note: That changing the function to as List(of Person) or ArrayList does work but given that I implement my own custom collections this is not optimal for me.

UPDATE: Ok so what I have worked out so far is that this problem is definitely associated with how the JavascriptSerializer uses the SimpleTypeResolver to resolve types. Basically if I do something like this

Public Function AddPersonList(ByVal PersonList As String) As PersonList

I can recreate the error using the following code.

Dim PersonList As PersonList = jsonSerializer.Deserialize(Of PersonList)(PList)

However when I provide my own custom type resolver along the lines of

Dim jsonSerializer As New JavaScriptSerializer(New MyCustomTypeResolver)

I can successfully create an instance of my custom list.Now I have worked out how to provide my own custom convertor in the web.config file. Along the lines of this....

<system.web.extensions>
<scripting>
<webServices>

[code]....

PSS: I have tried to use the assembly fully qualified name as specified in the docs for the SimpleTypeResolver (SimpleTypeResolver MSDN) but this throws a "Operation is not valid due to the current state of the object." exception - which is an error caused when the TypeResolver cannot resolve the name?

My problem was never passing in a List(of Object) into my webservice (I simply posed the question as such to simplify it for stackoverflow). In such a case I would be willing to completely accept using a Generic List(of) but my problem was actually that one of my custom objects implemented a property with a strong typed List(of) so for example:

Customer {CustomerID AS Guid, FirstName AS String, LastName AS String, EmailAddresses AS EmailAddressList}

which now needs to be changed to

Customer {CustomerID AS Guid, FirstName AS String, LastName AS String, EmailAddresses AS List(Of EmailAddress)}

This is admittedly not the end of the world and is probably better in the webservice context (as you have suggested) but definitely a detriment when it comes to internal application usage of my Collection properties. What this means is that once I have this property I either need to cast it to my CustomCollectionList every time I want to use some advanced feature or I need to implement another property which exposes the CustomCollectionList.

View 5 Replies

Accessing Elements Of Readfield?

May 9, 2012

I've managed to get my CSV file opened and the individual elements of each line read into an array. I've also managed to count and list the number of elements in the first row (i.e. the column headers).


[code]...

listOfNewFileRecords.Add(currentRow)' ADD EACH RECORD TO THE LIST AS THE FILE IS BEING READ Now the next stage is to access various cells within the whole opened file, so that I can condition/modify the text.So does 'ListOfNewFileRecords' have a way/method of accessing a particular element, in each record of the 'List'? I've tried using the intellisense, but can't make enough sense out of it to get anything to work.

View 11 Replies

Accessing XML Elements With LINQ Using .net (not C#)?

Nov 29, 2011

how to search XML trees with LINQ using VB.net. I've found some very helpful posts for C#, but none for VB.net?How would I use LINQ to XML to get the value from example XML Getting a set of elements using linq How to get elements value with Linq To XML I want to get the inputlocation for the process where name = "MyProcess1" Based on the example links above, I have been trying code like this:

Dim inputLocation As String = xdocument.Descendants("Configurations").Descendants("process").First(Function(c) c.Element("name").Value = "MyProcess1").Element("inputLocation").Value

But the code is not returning any values. here is the xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Configurations>
<process>

[code]....

View 1 Replies

Passing A JSON Object As A Dictionary(Of String, Object) To WCF Web Service?

Sep 8, 2011

I'm trying to setup a WCF web service to be consumed by JavaScript using JSON and jQuery.I've noticed that you can send JSON without a DataContract if the service method parameters match the naming structure of the JSON object:

<ServiceContract(Namespace:="http://foo.com/bar")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>

[code]....

View 1 Replies

Accessing Elements In A Multidimensional Array Of Arbitrary Dimensions?

Jul 3, 2010

I'm trying to write some of my own linear algebra methods, and I'd like them to work independent of the number of dimensions of the array. However, there doesn't seem to be any generic method, that I can see, for looking up a particular element in an array of arbitrary size. I mean I could write code to find the rank and then use (), (,), (,,), (,,,), etc, but that seems rather cumbersome.

View 4 Replies

Set ListBox Item Text Without Knowing What Kind Of Object It Is

May 14, 2010

I'm creating an editable ListBox control, where the user can double-click an item to edit it. When double-clicked, I simply overlay a TextBox over the item, so the user can change the text and then commit it by pressing Enter or leaving the TextBox. The 'commit' is simply this:[code]where 'editingIndex' is the index of the item being edited, and 'textBox' is the TextBox object.If the ListBox contains strings, this works just fine. The item being edited is replaced by the textbox Text string.However, if the ListBox contains some other object (let's say a custom class), this is a problem! It still "works", in that it still sets the text of the item, but the item is no longer an instance of that custom class! It is now a String, and all other information about the item is lost. So, I really want to let the user be able to change the text representation of ANY object, without replacing the object with a string. Obviously, I cannot know how the object displays its text (well, by the ToString function of course, but I cannot know what the ToString function returns).Now, I am having a few ideas how to approach this, but none really work the way I want. I am pretty sure that I'm going to have to provide some kind of event that the user has to handle. I'm thinking something like this:

- When the item edit is committed, an event is raised
- This event contains the Item being edited (as an object, the user has to cast it himself), and the new text of the item.-
- The user handles this event, and assigns the new text to the correct property.

For the Person class, this could look something like this.My ListBox should raise this event, and assign the new item like this.[code]I think this should work (although I haven't tested it), but there's one problem with this approach:When the items are just strings, the user still needs to implement this event handler, while he shouldn't have to (I can simply assign the new text string to the item). So, if the user is simply using strings, he still needs to do this for every instance of my listbox:[code]So what I'm really looking for is a way so that I can implement the default behavior (for String items), and still allow the user to override this behavior if he is not using strings.I may be overlookihe obvious solution here, but I can't figure it out... Overriding is done when you inherit a class, but the user isn't going to inherit my custom listbox (well he CAN, but he shouldn't have to). He is just going to handle the event. And if he doesn't handle the event, my listbox uses the default implementation.

View 9 Replies

Convert Custom JSON Object To A .NET Object?

Apr 5, 2012

I have a JSON object that looks like this.

{
"Errors":{
"err1":[
//* Array of err1 objects

[code]....

PD: I'm currently using Newtonsoft's JSON.Net library.

Public Sub New(ByVal jsonText As String)
Dim jObject As JObject = jObject.Parse(jsonText )
Dim jErrors As JToken = jObject("Errors")
Dim jS = New JsonSerializer()

[code]....

View 3 Replies

Converting String Back To Array For Accessing Individual Elements

Aug 9, 2011

I have the following function,
Dim results() As Object = Me.Invoke("webdirect", New Object() {Company, LocationCode, CustomerNumber, OrderNumber, OrderRef, OrderDate, WebLines})
o_Company = CType(results(1),System.Nullable(Of Integer))
o_LocationCode = CType(results(2),String)
o_CustomerNumber = CType(results(3),String)
[Code] .....

So the return type of this function is a string, but I would like to get it back to its original form so I can access the individual sections i.e. o_LocationCode,o_CustomerNumber, etc how can I do that ?

Entire functions looks like this
Public Function webdirect(<System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal Company As System.Nullable(Of Integer), <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal LocationCode As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal CustomerNumber As String,
[Code] .....

Called like this
Dim returnArray As String
returnArray = client.webdirect(10, "123", "123", "123", "147", "2011-11-1", webLinesArray, 10, "", "", "", "", "", webRespArray)
No errors on run time but the string seems to be just blank, thats why i was wondering how I convert the string back to the array so I can access the individual elements.

View 1 Replies

Access Html Elements Having Same Names And Values By Program?

Jun 14, 2012

There are some html buttons which dont have id . i want to access these html buttons which have the same type name and values . But i cant able to access then due to their same names and values [code]...

View 1 Replies

Accessing XML File Using JavaScript?

Dec 8, 2009

Am trying to read in data from an xml file but using javascript which is embedded into my asp.net|vb code. I am new to asp.net but coming from a programming background

View 1 Replies

VS 2010 Accessing Variable Names At Runtime?

Sep 30, 2010

Is there any way to access your variable names at runtime? Is there any kind of collection you can loop through?

View 2 Replies

Object Object Error In Using JSON

Nov 17, 2011

I have a problem in returning a value in JSON in vb .net.[code]My scenario is that, when i pressed the button then it should alert the value returned by the getValue function but in my case it always alert an error of [Object Object].

View 1 Replies

Accessing Dynamic JavaScript Content From Onclick?

Dec 28, 2009

I have read previous posts and used suggestions about firebug and selenium etc. I am still a newbie and am still pretty confused as how to implement this. I am trying to access URLs that appear when I click on a link. I have accessed the JavaScript code and the function just has a couple of parameters which I have no idea how to intercept using vb.net or C# etc.

View 2 Replies

Javascript - Accessing HTML Checkbox In Code Behind?

Nov 6, 2011

I have a HTML checkbox which will perform a simple validation on another textbox, so the textbox will only be enabled if the checkbox is checked, but I also want to access this checkbox control in code behind to check and uncheck it. I don't think I can use the runat="server" because on the onClick event which will cause ('<%=uitxtVouTypeRedeemValue.ClientID%>') to be output as plain text.

<input type="checkbox"
onclick="document.getElementById('<%=uitxtVouTypeRedeemValue.ClientID%>').disabled =(this.checked)?0:1" id="uichkVouTypeRedeemable" />

View 2 Replies

C# - Accessing Members With Case-sensitive Names Across Languages In .NET

Apr 14, 2009

I just came across an interesting scenario. I have a class in C#:

[Code]...

As C# is case sensitive, this will treat the two variables A and a as distinct. I want to inherit the above class in my VB code, which is not case sensitive. How will the VB code access the two distinct variables A and a?

View 4 Replies

.net - Deserialize JSON Into An Object?

Sep 13, 2011

I'm having an issue with getting some of the values from with this json string:

{
"kind": "shopping#products",
"etag": ""YZWJaKE3MHROIW8rCIlu9mAACLM/6qxBB-GwuSPy5L3_zVS6sS2NYFI"",
"id": "tag:google.com,2010:shopping/products",
"selfLink": "https://www.googleapis.com/shopping/search/v1/public/products?country=US&

[code]....

View 2 Replies

Could Not Deserialize JSON Object?

Feb 23, 2010

We are trying to consume WCF service which returns employee details in JSON Format.like:

{"d":[{"_type":"Employee:#","BigThumbNailURI":null,"ID":1,"Name":"E1"},{"_type":"Employee:#","BigThumbNailURI":null,"ID":2,"Name":"E1"}]}

From VB.net code behind when I am trying to deserialize it it's stating that "Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''."

View 2 Replies

Deserialize JSON To LINQ Object?

Mar 24, 2011

In VB.Net class, I have a JSON data as string. I want to convert them to LINQ class Object.[code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved