aspJSON icon indicating copy to clipboard operation
aspJSON copied to clipboard

Error when nesting

Open dtrillo opened this issue 7 years ago • 7 comments

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.

dtrillo avatar Sep 11 '18 10:09 dtrillo

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 avatar Sep 11 '18 11:09 rcdmk

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.

rcdmk avatar Sep 11 '18 11:09 rcdmk

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 avatar Sep 11 '18 11:09 dtrillo

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 avatar Sep 11 '18 13:09 dtrillo

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!

dtrillo avatar Sep 13 '18 11:09 dtrillo

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

rcdmk avatar Sep 13 '18 12:09 rcdmk

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 avatar Sep 30 '22 04:09 rcdmk