473,378 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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=VBScript %>
<script language="jscript" runat="server">
var json = {"widget":[{"value":"text 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.widget) & "<br />"
Response.Write "IsObject: " & IsObject(json.widget) & "<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 10542
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=VBScript %>
<script language="jscript" runat="server">
var json = {"widget":[{"value":"text 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.widget) & "<br />"
Response.Write "IsObject: " & IsObject(json.widget) & "<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******@NOyahoo.SPAMcomwrote in message
news:O7**************@TK2MSFTNGP06.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=VBScript %>
<script language="jscript" runat="server">
var json = {"widget":[{"value":"text 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.widget) & "<br />"
Response.Write "IsObject: " & IsObject(json.widget) & "<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******@NOyahoo.SPAMcomwrote in message
news:O7**************@TK2MSFTNGP06.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=VBScript %>
<script language="jscript" runat="server">
var json = {"widget":[{"value":"text 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.widget) & "<br />"
Response.Write "IsObject: " & IsObject(json.widget) & "<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
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
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...
1
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...
13
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...
1
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"%>...
7
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...
2
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...
2
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.