aspJSON icon indicating copy to clipboard operation
aspJSON copied to clipboard

add lcase as an option when LoadRecordset

Open dtrillo opened this issue 6 years ago • 3 comments

Hi. I wonder if if is possible to add a new parameter on functions LoadRecordset and LoadFirstRecord to allow that the key can be always lower case. I do like this:

public sub LoadFirstRecord(byref rs, lcaseall) ' Change 3.8.2 dim field

	for each field in rs.fields
		k = field.name: if lcaseall then k = lcase(k)
		add k, field.value
	next
end sub

dtrillo avatar Mar 06 '19 15:03 dtrillo

There is a new option, in order to not loose compatibility with previous versions, just creating a new function:

' Load properties from the first record of an ADO RecordSet object ' @param rs as ADODB.RecordSet public sub LoadFirstRecord2(byref rs, lcaseall) ' Change 3.8.2 dim field

	for each field in rs.fields
		k = field.name: if lcaseall then k = lcase(k)
		add k, field.value
	next
end sub
public sub LoadFirstRecord(byref rs) 
	LoadFirstRecord2 rs, false
end sub

dtrillo avatar Mar 06 '19 15:03 dtrillo

Hi. I think this could be a property to set in the object and all parsing from it would use lowercase keys. What do you think?

Something like this:

<%
set json = New JSONObject
json.LowerCaseKeys = true ' hypothetical property

' from here on every key added would be in lowercase
' ...
%>

rcdmk avatar Mar 10 '19 22:03 rcdmk

That would be great! So, you need to modify serializeObject, don't you? I think this option will reduce problems with the response, instead of working on the model of the database.

dtrillo avatar Mar 11 '19 08:03 dtrillo