473,379 Members | 1,167 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,379 software developers and data experts.

asp datatypes converted to JSON

hi guys,
i thought you might be interested in a nice JSON class which converts
ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into
JSON so that javascript can easily understand it ...
you'll find the demonstration and the download here
http://fabiankoehler.de/wdb/2007/04/...asp-datatypes/

Apr 26 '07 #1
5 3797
michal wrote:
hi guys,
i thought you might be interested in a nice JSON class which converts
ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into
JSON so that javascript can easily understand it ...
you'll find the demonstration and the download here
http://fabiankoehler.de/wdb/2007/04/...asp-datatypes/

Ummm - ASP is not a language with datatypes. Perhaps you meant
"vbscript". You also seem to forget that ASP can use other scripting
languages such as jscript. You might want to update your page.

--
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.
Apr 26 '07 #2
On Apr 26, 7:01 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
michal wrote:
hi guys,
i thought you might be interested in a nice JSON class which converts
ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into
JSON so that javascript can easily understand it ...
you'll find the demonstration and the download here

http://fabiankoehler.de/wdb/2007/04/...asp-datatypes/

Ummm - ASP is not a language with datatypes. Perhaps you meant
"vbscript". You also seem to forget that ASP can use other scripting
languages such as jscript. You might want to update your page.

--
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.
thanks ive changed that...

Apr 27 '07 #3
On Thu, 26 Apr 2007 11:30:49 -0500, michal <mg****@gmail.comwrote:
hi guys,
i thought you might be interested in a nice JSON class which converts
ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into
JSON so that javascript can easily understand it ...
you'll find the demonstration and the download here
http://fabiankoehler.de/wdb/2007/04/...asp-datatypes/
You might find refactoring that generateValue function into several
smaller functions worthwhile. I have a function I use for debugging
which looks like this:

Function Repr(val)
Dim r
Select Case False
' For Scalars and objects other than Err, the name of the Repr
' function can be derived directly from the value's type
Case IsObject(val), val Is Err
On Error Resume Next
Set r = GetRef("Repr::" & TypeName(val))
On Error Goto 0
' The type of the Err object is "Object", so its Repr function
' must be manually chosen
Case Else
Set r = GetRef("Repr::Err")
End Select

If IsEmpty(r) Then Repr = TypeName(val) Else Repr = r(val)
End Function

Then simple specialized functions for each data type can be defined:

Function [Repr::Integer] (val)
[Repr::Integer] = "CInt(" & val & ")"
End Function

Function [Repr::Date] (val)
[Repr::Date] = "#" & val & "#"
End Function

Function [Repr::String] (val)
[Repr::String] = """" _
& Replace(val, """", """""") _
& """"
End Function

Function [Repr::Boolean] (val)
[Repr::Boolean] = CStr(val)
End Function

Function [Repr::Variant()] (val)
With CreateObject("Scripting.Dictionary")
Dim elm: For Each elm In val : .Add .Count, Repr(elm) : Next
[Repr::Variant()] = "Array(" & Join(.Items, ", ") & ")"
End With
End Function

This allows you to easily define Repr functions for user-defined types:

Class Foo : End Class

Function [Repr::Foo] (val)
[Repr::Foo] = "New Foo"
End Function

You should be able to use a similar strategy to emit JSON-encoded data.

--
Justin Piper
Bizco Technologies
http://www.bizco.com/
Apr 27 '07 #4
sorry the article is available under a new address:
http://www.webdevbros.net/2007/04/26...asp-datatypes/
we just got our new domain :)

Apr 27 '07 #5
hi justin,
thanks really for your reply, cause as i can see i can still discover
something new in Vbscript... i havent seen the getRef function yet..
its awesome.. will play around and this might be a good refactoring
suggestion ;)
thanks!

Apr 27 '07 #6

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

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
16
by: G Matthew J | last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm This is more or less in response to Mr Crockford's admonition a few months ago, "fork if you must". Ironically, although in that usenet post...
20
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... ...
2
by: Kevin Newman | last post by:
Hello, I noticed that the JavaScript library for JSON posted on json.org (http://www.json.org/json.js) is modifying Object.prototype (adding a method - toJSONString). I thought this was...
3
by: Adam | last post by:
I'm trying to retrieve some values from a json object, but instead it's giving me the property name. For example: var json = { "glossary": { "title": "example glossary" } }; console.log(json);...
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...
23
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns...
9
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
3
by: fjm | last post by:
I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored. I...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.