As the title suggests, I would like to be able to serialize and deserialize Foxpro objects from and to JSON. I have found a couple of JSON implementations that will serialize and deserialize Foxpro objects, but they are not capable of serializing anobject, then taking the JSON they generated from the object, and deserializing it back into an exact copy of the original object. That makes it impossible to use them to save and restore data. Does anyone know of a way to serialize/deserializea foxpro object for purposes of saving and restoring data?Alternatively, is there a better way of saving a foxpro object? I thought of using the SAVE TO command but unfortunately that does not work with objects. One of the best concepts you have in VFP about record object generation is SCATTER NAME and GATHER or INSERT FROM NAME. Especially with the EXECEPT and ADDITIVE clauses you have easy ways to do object to record transformations and vice versa.The only precondition is, you have tables in the schemas your objects need and vice versa.
If you have individual dynamically generated objects, that's not an easy task. But since we're used to the paradigm of having a defined schema with tables that shouldalso be possible to expand to the scope of the objects.Finally VFPs controls rather work best with DBFs and/or cursors and the only things I use in an object for each record fashion are ActiveX controsl, but I also maintain their data in cursors for easy transfer with the same biz and data access objectsused for VFP cursor driven controls or more general UI and biz rules and application logic. Your need with this may vary, of course and objects are nice to be passed, for example, but for me only an adaptive use for external modules like ActiveX.Bye, Olaf.Olaf Doschke - TMN Systemberatung GmbH. Whatever is fine with you, just realise, if you store some JSON string into a memo field you don't have the chance to query with normal where clauses, you don't have indexed columns and much more, that is in the nature of normalised relational databases,you just have a bunch of json in memo fields, most probably. On the other side they can have different structure per record, you have all data in string format (though with JSON/Javscript specific format) and may do some kind of fulltext search.
Sounds nicer,thatn it is, as you can only index LEFT(memo,240) at max and need LIKE '%searchterm%' queris, that are not optimizable.If your objects are a atomic information to you and search criteria are in extra fields, that's fine anyway. So the final judgement of what's best for you is on you.Last not least: There's nothing wrong with a JSON library in general, it's purpose surely is working with JSON in website APIs besides browser automation and interoperation with javascript frameworks.Bye, Olaf.Olaf Doschke - TMN Systemberatung GmbH.
This document removes inconsistencies with other specifications of JSON, repairs specification errors, and offers experience-based interoperability guidance.The handling of JSON data in ABAP is based on the following principles:. A JSON-XML format maps JSON data to XML. XML readers and XML writers in sXML Library support JSON-XML and can be used as parsers and renderers of JSON data. Direct transformations can be made between ABAP and JSON. Here, a canonical JSON representation of ABAP data called asJSON can be used for the identity transformation ID.To learn more aout Json, Check one of the following JSON Books:.Handling of JSON in ABAPThe handling of JSON data in ABAP is based on the following principles:( ).
A JSON-XML format maps JSON data to XML. XML readers and XML writers in sXML Library support JSON-XML and can be used as parsers and renderers of JSON data. Direct transformations can be made between ABAP and JSON. Here, a canonical JSON representation of ABAP data called as JSON can be used for the identity transformation ID.IFSXML=COXTJSON InterfaceJSON-XML is a special XML format that enables JSON data to be described using an XML representation. A new format, IFSXML=COXTJSON, has been added to the sXML Library, which enables to handle JSON using JSON-XMLThe canonical JSON representation asJSON defines a mapping between ABAP types and JSON.This is used in serializations and deserializations using the identity transformation ID.JSON data can be specified in various forms as an XML source in the statement CALL TRANSFORMATION and a JSON writer can be specified as target.The identity transformation ID supports JSON by using asJSON. Sample Implementation of sXML ABAP to JSONHere an excellent sample for the implementation of IFSXML=COXTJSON interface ( ).
ABAP JSON Parser And Mapper Sample ClassesIn this section, you will find 2 opensources ABAP Class to handle all the actions when handling ABAP & JSON. JSON Parser ClassA clean, reliable and compliant JSON parser and mapper to ABAP data the kind your mother would have encouraged you to hang out with.