JSON Class Update
Since my initial post regarding this class, work has continued improving it. A number of fixes and enhancement can be found in the latest version…

  • Fixes to parse method – There was a problem with brace matching for “{}” and “[]” when nested in certain ways.
  • Fixes to UseUTCDatetime functionality – rules are now as follows:
    • UseUTCDateTime = .F. && Datetimes will stringify including Local offset from UTC
    • UseUTCDateTime = .T. && Datetimes will stringify as UTC equivalent for Local
    • Parse() && will always return Local equivalent
  • Fixes to GetTimezoneOffset method – now respects Standard/Daylight boundaries of datetimes
  • Fixed Stringify – cursors are serialized to valid JSON now
  • Added KeyForCursor property – this allows a JSON key to be specified for identifying cursors (defaulted to “VFPData”)
  • Enhanced Stringify and Parse methods – they now handle the VFP Collection class with aplomb
  • Added KeyForItems property – when serializing Collections, the key for the contained JSON object’s array property can be defined (defaulted to “items”)
  • Renamed DateSerializationType property – it is now ParseDateType
  • Enhanced Parse – JSON class will now (optionally) respect Class and ClassLibrary properties if they exist in a JSON object being deserialized (see ParseRespectClass property). This means that if you Stringify() a VFP Form and then Parse() the JSON (with ParseRespectClass = .T.) you will get a Form object back rather than an Empty object with the same properties as the Form.

I would consider the JSON class production-ready at this point. This doesn’t mean that bugs won’t be found in the future, but it has been hammered on enough that I wouldn’t hesitate to use it in a production application.

Visual FoxPro Now Listed
I got in touch with Douglas Crockford and was able to get Visual FoxPro listed on JSON.org with a link to my initial post. I appreciate Douglas Crockford taking the time out of his busy schedule to list Visual FoxPro on the JSON site.

Special Thank You
Nearly all of the fixes and enhancements provided in this version of the JSON class were made possible by the help and prodding I received from Frank Dietrich of Berlin. He is an extremely bright fellow. Implementing the Timezone and Daylight vs. Standard stuff drove us both to the brink. I sincerely doubt I could have done it without his help.

Download the JSON class library (approx. 59 KB)

download contains the JSON class in both VCX and PRG format. They are the same. Use
whichever one you prefe