omegastripes / VBA-JSON-parser

Backus-Naur Form JSON Parser based on RegEx for VBA
GNU General Public License v3.0
107 stars 44 forks source link

there is a error aftering use 2 times #30

Closed enponder closed 2 years ago

enponder commented 2 years ago

hi I referenceed the JSON for 2 times in the same module, then threw a error that it said "This array is fixed or temporarily locked".the follow is code example:

Dim subtitles_json_one As String, vJson, vStateAs String
Dim subtitles_json_two As String
JSON.Parse subtitles_json_one, vJson, vState
JSON.Parse subtitles_json_two, vJson, vState 

I know why it's erroring out. This error occurs because subtitles_json_onegenerates a vjson, and continues to use the vjsonthat has not been reset in subtitles_json_two. I would like to know how to reset vjsonso that I can re-assign vjson. I have tried similar erase statement but still can't reset vjson. If you continue without resetting vjson, you will get an error that it said "This array is fixed or temporarily" I know I can redefine a new variable in place of vjson, but apparently I'm just bypassing such issues, but I can't figure out how to reset vjson

The code below is the solution, by defining new variables, but that's not what I want, what I want is how to be able to reset the data of the vjson

Dim subtitles_json_one As String, vJson, vState As String
Dim subtitles_json_two As String, sJson, sState As String
JSON.Parse subtitles_json_one, vJson, vState
JSON.Parse subtitles_json_two, sJson, sState 
omegastripes commented 2 years ago

Hi @enponder, Unfortunately I'm not able to reproduce the error you faced. Could you please attach the whole workbook to the message, including all JSON related modules and subtitles_json_one, subtitles_json_two content (at least the parts reproducing the error, removed sensitive data). Drag'n'drop zipped workbook into the message to attach it.

enponder commented 2 years ago

Hi @enponder, Unfortunately I'm not able to reproduce the error you faced. Could you please attach the whole workbook to the message, including all JSON related modules and subtitles_json_one, subtitles_json_two content (at least the parts reproducing the error, removed sensitive data). Drag'n'drop zipped workbook into the message to attach it.

I just debuged my code, I found that I made a programming mistake in it. This is totally wrong in my code logic. In generally, I'm looping through the child elements of the vjson, but at the same time I'm trying to reassign the vjson again. This is completely a code logic error, not a json module error. Now I've fixed it and it's working fine. I'm so sorry for wasting your time reading the problem caused by the logic error in my code, I'm so sorry

omegastripes commented 2 years ago

No problem! Good luck with your project.