West Wind Internet and Client Tools
wwJSONSerializer WriteValue
Gravatar is a globally recognized avatar based on your email address. wwJSONSerializer WriteValue
  uprightguy
  All
  Dec 16, 2020 @ 09:12am

I was having issue with the Cursor to Json function of the class. When I walked it through based on an example from the forum.

AddProperty(loGrid,"rows","cursor:TQUery")

in the writevalue(lvValue) function it has a case statement that never fires the this.writeCursor function to create a JSON from the cursor.

CASE lvValue = "cursor:" OR lvValue ="cursor_rawarray:" OR lvValue = "cursor_legacy"

However once i changed that line to

CASE AT("cursor:",lvValue)>0 OR AT("cursor_rawarray:",lvValue)>0 OR AT("cursor_legacy",lvValue)>0

the function fired correctly and I was able to generate a JSON from the cursor.

Gravatar is a globally recognized avatar based on your email address. re: wwJSONSerializer WriteValue
  Rick Strahl
  uprightguy
  Dec 16, 2020 @ 11:40am

SET EXACT ON will affect this.

All West Wind libraries assume that SET EXACT OFF - if necessary you can toggle on and off.

Visual FoxPro Environment Requirements

It's an unfortunate legacy side-effect from an original perf oriented optimization that dates back to the original versions in the mid-1990's. Probably the only real regret I have as a framework choice with all the tools 😦

Going to fix this in the serializer though since there's an easy and efficient workaround.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwJSONSerializer WriteValue
  Rick Strahl
  uprightguy
  Dec 16, 2020 @ 02:08pm

Just as a heads up I made the following change in wwJsonSerializer for the cursor serialization:

	CASE INLIST(lcType,"C","M","V")
		DO CASE
		 CASE LEFT(lvValue,6) == "cursor"		 
		    IF LEFT(lvValue,7) == "cursor:" OR  LEFT(lvValue,16) == "cursor_rawarray:" OR LEFT(lvValue, 13) == "cursor_legacy"
				this.WriteCursor(@lvValue)
			ELSE
				this.WriteString(@lvValue)
			ENDIF
		OTHERWISE			
			this.WriteString(@lvValue)
		ENDCASE

More complex than it has to be but this should minimize the code that has to execute in arguably the most common property type path through the serializer.

+++ Rick ---

© 1996-2025