memtimintursun / aspjson

Automatically exported from code.google.com/p/aspjson
0 stars 0 forks source link

problem with empty values... #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. in the below code:
Set member = jsObject()
member("Sonuc") = 0
member("Mesaj") = "Tamam"
member("Test") = Test 

member.Flush

----
if one of the variables is empty, the returned json gives parseerror.

What is the expected output? What do you see instead?

The output should be like this :
----------
{"Sonuc":0,"Mesaj":"Tamam","Test":""}
----------
But, if the variable Test is empty then the result was like this :
----------
{"Sonuc":0,"Mesaj":"Tamam","Test":}
----------
What version of the product are you using? On what operating system?

I'm using JSON_2.0.2.asp on a classic asp project running on windows 2000
server.

Please provide any additional information below.

I've found a quick solution to this problem by adding modifying this code :
I've put these lines 
--------
        if isempty(v) then
            v = ""
        end if
--------
to this function:
--------
    ' - data maluplation
    ' -- pair
    Public Property Let Pair(p, v)
        if isempty(v) then
            v = ""
        end if
        If IsNull(p) Then p = Counter
        Collection(p) = v
    End Property
--------

Maybe you'll find a better solutions but this is now working for me... BTW,
Thanks for the code. Your code was simplest to implement and saved me time...
if you are in Istanbul, I can buy you a coffee (or beer, whatever you want :)

Original issue reported on code.google.com by timucink...@gmail.com on 5 Jan 2009 at 9:22

Attachments:

GoogleCodeExporter commented 8 years ago
This solution correctly but isn't reuseble. For example
{{{
member("Sonuc") = 0
member("Mesaj") = "Tamam"
member("Test") = Test 

If IsEmpty(member("Test")) Then ' ????
' bammmm
End If
}}}

We must check in render time,
{{{
Class jsCore
...
Public Function toJSON(vPair)
        Select Case VarType(vPair)
            Case 0  ' Empty
                toJSON = ""
            Case 1  ' Null
                toJSON = "null"
...
}}}

I'm live near Istanbul, in Yalova. How to contact with us?

Original comment by tugrulto...@gmail.com on 7 Jan 2009 at 2:11

GoogleCodeExporter commented 8 years ago
I had to find a quick fix so I left the real fix to you. :) Now it's up to you 
for
the fixed version. (JSON_2.0.3.asp)

My email is timucinkizilay at gmail.com. you can contact me from this email.

Original comment by timucink...@gmail.com on 7 Jan 2009 at 2:28

GoogleCodeExporter commented 8 years ago

Original comment by tugrulto...@gmail.com on 8 Nov 2009 at 7:17