Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > asp datatypes converted to JSON

Reply
Thread Tools

asp datatypes converted to JSON

 
 
michal
Guest
Posts: n/a
 
      04-26-2007
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/

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-26-2007
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.


 
Reply With Quote
 
 
 
 
michal
Guest
Posts: n/a
 
      04-27-2007
On Apr 26, 7:01 pm, "Bob Barrows [MVP]" <(E-Mail Removed)>
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...

 
Reply With Quote
 
Justin Piper
Guest
Posts: n/a
 
      04-27-2007
On Thu, 26 Apr 2007 11:30:49 -0500, michal <(E-Mail Removed)> 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/


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:ate] (val)
[Repr:ate] = "#" & 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/
 
Reply With Quote
 
michal
Guest
Posts: n/a
 
      04-27-2007
sorry the article is available under a new address:
http://www.webdevbros.net/2007/04/26...asp-datatypes/
we just got our new domain

 
Reply With Quote
 
michal
Guest
Posts: n/a
 
      04-27-2007
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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lib to generate XML/JSON[P] output from a DTD/XSD/JSON Schema/etc Acácio Centeno Python 1 02-15-2013 07:34 AM
I am facing an issue while decoding json string using json.loads sajuptpm Python 2 12-28-2012 07:16 AM
[ANN] Security Fix json-1.1.7 for json_pure and json gems Florian Frank Ruby 0 06-30-2009 05:18 PM
"JSON for ASP" at json.org Tuğrul Topuz ASP General 1 06-27-2008 11:37 PM
interrogating database for field names/datatypes? ASP .Net 2 07-28-2003 01:39 AM



Advertisments