473,804 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jscript json used in vbscript?

I'm aware that there are significant differences between VBScript objects
and JScript objects but that doesn't mean something like the following
should give me such troubles?

<%@ Language=VBScri pt %>
<script language="jscri pt" runat="server">
var json = {"widget":[{"value":"te xt here"},{"value" :123}]};
</script>
<%
Response.Write json.widget & "<br />"
For Each o In json.widget
Response.Write o.value & "<br />"
Next

Response.Write "IsArray: " & IsArray(json.wi dget) & "<br />"
Response.Write "IsObject: " & IsObject(json.w idget) & "<br />"

Response.Write json.widget(0). value '<- won't work...?
%>

The above code return the following results:

[object Object],[object Object]
text here
123
IsArray: False
IsObject: True

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'widget'

/asp/json.asp, line 16
Anyone an idea how to get the dot notation:
json.widget(0). value
to work?
Jun 1 '07 #1
5 10580
Marc wrote:
I'm aware that there are significant differences between VBScript
objects and JScript objects but that doesn't mean something like the
following should give me such troubles?

<%@ Language=VBScri pt %>
<script language="jscri pt" runat="server">
var json = {"widget":[{"value":"te xt here"},{"value" :123}]};
</script>
<%
Response.Write json.widget & "<br />"
For Each o In json.widget
Response.Write o.value & "<br />"
Next

Response.Write "IsArray: " & IsArray(json.wi dget) & "<br />"
Response.Write "IsObject: " & IsObject(json.w idget) & "<br />"

Response.Write json.widget(0). value '<- won't work...?
%>

The above code return the following results:

[object Object],[object Object]
text here
123
IsArray: False
IsObject: True

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'widget'

/asp/json.asp, line 16
Anyone an idea how to get the dot notation:
json.widget(0). value
to work?
Like this:

Response.Write json.widget.[0].value
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 1 '07 #2

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcomwrote in message
news:O7******** ******@TK2MSFTN GP06.phx.gbl...
Marc wrote:
>I'm aware that there are significant differences between VBScript
objects and JScript objects but that doesn't mean something like the
following should give me such troubles?

<%@ Language=VBScri pt %>
<script language="jscri pt" runat="server">
var json = {"widget":[{"value":"te xt here"},{"value" :123}]};
</script>
<%
Response.Write json.widget & "<br />"
For Each o In json.widget
Response.Write o.value & "<br />"
Next

Response.Write "IsArray: " & IsArray(json.wi dget) & "<br />"
Response.Write "IsObject: " & IsObject(json.w idget) & "<br />"

Response.Write json.widget(0). value '<- won't work...?
%>

The above code return the following results:

[object Object],[object Object]
text here
123
IsArray: False
IsObject: True

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'widget'

/asp/json.asp, line 16
Anyone an idea how to get the dot notation:
json.widget(0). value
to work?

Like this:

Response.Write json.widget.[0].value
I Almost fell of my chair...

I know I was thinking to do it like that but for some reason I thought:
nooo, that won't work...

Thx Bob!!
Jun 1 '07 #3

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcomwrote in message
news:O7******** ******@TK2MSFTN GP06.phx.gbl...
Marc wrote:
>I'm aware that there are significant differences between VBScript
objects and JScript objects but that doesn't mean something like the
following should give me such troubles?

<%@ Language=VBScri pt %>
<script language="jscri pt" runat="server">
var json = {"widget":[{"value":"te xt here"},{"value" :123}]};
</script>
<%
Response.Write json.widget & "<br />"
For Each o In json.widget
Response.Write o.value & "<br />"
Next

Response.Write "IsArray: " & IsArray(json.wi dget) & "<br />"
Response.Write "IsObject: " & IsObject(json.w idget) & "<br />"

Response.Write json.widget(0). value '<- won't work...?
%>

The above code return the following results:

[object Object],[object Object]
text here
123
IsArray: False
IsObject: True

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'widget'

/asp/json.asp, line 16
Anyone an idea how to get the dot notation:
json.widget(0). value
to work?

Like this:

Response.Write json.widget.[0].value
--
btw
It does make me wonder how to know 'value'
I know how to do this in Javascript but am now stumped on that in
VbScript...

I tried :

For Each o In json.widget
Response.Write o.value & "<br />"
Response.Write json.widget.[o] & "<br />"
Next

but uhm... that's a no go...

and then... why isn't widget an Array?

Jun 1 '07 #4
Marc wrote:
btw
It does make me wonder how to know 'value'
Do you mean you want to enumerate the object's property names? There is
no way to do that in vbscript.
I know how to do this in Javascript but am now stumped on that in
VbScript...

I tried :

For Each o In json.widget
Response.Write o.value & "<br />"
Response.Write json.widget.[o] & "<br />"
Next

but uhm... that's a no go...

and then... why isn't widget an Array?
A javascript array is not a vbarray. They are different things. Google
for details

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 1 '07 #5
>btw
>It does make me wonder how to know 'value'

Do you mean you want to enumerate the object's property names? There is
no way to do that in vbscript.
Okay, I thought so, thx
>
>I know how to do this in Javascript but am now stumped on that in
VbScript...

and then... why isn't widget an Array?

A javascript array is not a vbarray. They are different things. Google
for details
Okay, thx Bob!
Jun 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
6035
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
5976
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client javascript code and work out what it does but I can't really write it from scratch.
1
2007
by: alaa | last post by:
I have the following code in an ASP page but it does not seem to allow a JScript to access VBScript variables. But if a VBScript accesses a variable in declared in a JScript TAG then it seems to work. Can anyone help <SCRIPT LANGUAGE ="VBSCRIPT" RUNAT="SERVER" Dim tes test = 10 </SCRIPT><SCRIPT LANGUAGE ="JSCRIPT" RUNAT="SERVER" Response.Write(test) </SCRIPT>
13
2489
by: Eric Robinson | last post by:
Hello, My ASP code creates an ADO recordset object on the server. Later on the same page, I have a javascript code snippet that I use to dynamically populate a drop-down box based on choices made in another drop-down box. Can this javascript (or a server-side equivalent) access the recordset object? --Eric
1
4229
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%> <!--#include virtual="/Connections/EmployeeStatusChange.asp" --> <%
7
5799
by: dkiernan | last post by:
I am stumped. I have several websites running on a 2003 IIS6 box, all running basically the same code (each site has its own home directory and copy of the code). All are running in the same App Pool. One site gives the 800a0006 error on a formatpercent, another site (on the same server) does not. Here's the kicker...the one site only fails if the number is LESS THAN 1.
2
4567
by: tunk | last post by:
I dont know where to start my question so let me tell you my story :) The ASP that cause me trouble is running on IIS that set ASP default language to JScript instead of VBScript. This ASP page is popped up by another ASP page and there are authentication, privilege and security stuff involved. And yes this page contain a lot of javascript. there is a <DIV></DIV> in this page for me. And my job is as simple as put another page between...
2
3327
by: ChrisO | last post by:
I've been pretty infatuated with JSON for some time now since "discovering" it a while back. (It's been there all along in JavaScript, but it was just never "noticed" or used by most until recently -- or maybe I should just speak for myself.) The fact that JSON is more elegant goes without saying, yet I can't seem to find a way to use JSON the way I *really* want to use it: to create objects that can be instantated into multiple...
3
1719
by: =?Utf-8?B?Sm9obkhvcmI=?= | last post by:
I have a problem with client-side VBSCRIPT on a page with auto-postback controls. I have generated a simple page with a listbox, set to autopostback. This works OK. If I then generate some client-side VBSCRIPT, VS creates a VBSCRIPT script block. Even if I delete everything within the block, just leaving the <script</scripttags, I get an error on the page if I click an item in the list box. If I use JScript, rather than VBScript, I don;t...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.