472,358 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 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 3741
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.