rcdmk / aspJSON

A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.
MIT License
204 stars 89 forks source link

add lcase as an option when LoadRecordset #88

Open dtrillo opened 5 years ago

dtrillo commented 5 years ago

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 commented 5 years ago

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
rcdmk commented 5 years ago

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
' ...
%>
dtrillo commented 5 years ago

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.