Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when nesting #82

Open
dtrillo opened this issue Sep 11, 2018 · 7 comments
Open

Error when nesting #82

dtrillo opened this issue Sep 11, 2018 · 7 comments
Labels
bug fix-in-development A fix for this issue was implemented on current development branch.

Comments

@dtrillo
Copy link

dtrillo commented Sep 11, 2018

Hi all.
I have been using the aspJSON 3.3.1 and I have no problem by using this:
Dim oJSON
set oJSON = new JSONobject
SqlSelect = "select * from table1"
Set AdoRS = GetRecordSet(sCadenaConexion, SqlSelect)
oJSON.defaultPropertyName = "prop1"
oJSON.LoadRecordset AdoRS

	SqlSelect = "select * from table2"
	Set AdoRS = GetRecordSet(sCadenaConexion, SqlSelect)
	oJSON.defaultPropertyName = "prop2"
	oJSON.LoadRecordset AdoRS

I want the result to include several queries as a response, each one being change the name using defaultPropertyName

I have tried aspJSON 3.8.1, but I got this error:

JSONobject error '800a0002'

A property already exists with the name: [[JSONroot]].

/api/inc/jsonObject.class.asp, línea 495 

AdoRS is a recordset object that fit perfect with LoadRecordset.

When using 3.3.1, the result is correct.

When using 3.8.1, the error raise.

@rcdmk
Copy link
Owner

rcdmk commented Sep 11, 2018

Hi. This incorrect and intended behaviour.
To do the same in newer versions you can instantiate a new jsonObject, load the recordset in it and add it as a property to the root one:

<%
' ...
Set oJson2 = new jsonObject
oJson2.DefaultPropertyName = "prop2"
oJson2.LoadRecordset AdoRS

oJson.Add "prop2" oJson2("prop2")
%>

@rcdmk
Copy link
Owner

rcdmk commented Sep 11, 2018

Sorry. I misunderstood what you said.
The correct behaviour is to work as before.
I'll have to take a look at what changed since then and fix this.

Thanks.

@dtrillo
Copy link
Author

dtrillo commented Sep 11, 2018

Thanks for the reply.
I guess that the old way is not possible to use it any more, because with version 3.3.1 works perfectly!

@dtrillo
Copy link
Author

dtrillo commented Sep 11, 2018

When using 3.4, OK
When using 3.5.2, fails,
Microsoft VBScript runtime error '800a01ca'

Variable uses an Automation type not supported in VBScript: 'TypeName'

/api/inc/jsonObject.class.asp, línea 518

In 3.4.1 works, but in 3.4.2, fails!!
Microsoft VBScript runtime error '800a01ca'

Variable uses an Automation type not supported in VBScript: 'TypeName'

/zsp2/api/inc/jsonObject.class.asp, línea 522

Both lines, 518 and 522 are:
elseif isObject(obj) and typeName(obj) <> "IStringList" then

from the add method.

Hope it helps!

@dtrillo
Copy link
Author

dtrillo commented Sep 13, 2018

Hi again.
I've been testing several versions, trying to figure out what is going on with this issue. And got a solution!!

With 3.4.1, everything works. I had some problems due to my data, but they are now fixed from errores (mainly, due to " in strings, changed to `).

With 3.4.2, the error appears in line 522 (as said in the previous message).
With 3.8.1, the error is:
JSONobject error '800a0002'

A property already exists with the name: [[JSONroot]].

/zsp2/api/inc/jsonObject.class.asp, línea 495

As I told you, during my tests, I had this error 'A property already exists ...' because of the data, but now, everything is fixed, so no need to get that error.

I was able to fix the error on version 3.8.1.
On LoadRecordSet, you have this line 886:
"add JSON_ROOT_KEY, arr"

In version 3.4.1, this same line is: "add i_defaultPropertyName, arr"

I guess that when you modify this line was because of something, but if in 3.8.1 i change to previous version 3.4.1, everything works!

@rcdmk
Copy link
Owner

rcdmk commented Sep 13, 2018

Hi. Thank you very much for your effort reporting and testing this.
I should work on this soon.

@rcdmk
Copy link
Owner

rcdmk commented Sep 30, 2022

Hi,
Not so soon as I expected, but I have this fix on the development branch: 92d688e.

Please feel free to test that out.

Best,
Ricardo

@rcdmk rcdmk added bug fix-in-development A fix for this issue was implemented on current development branch. labels Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix-in-development A fix for this issue was implemented on current development branch.
Projects
None yet
Development

No branches or pull requests

2 participants