Forum Replies Created

Page 4 of 4
  • Paul Mulroney Mulroney

    Member
    January 16, 2018 at 3:56 am in reply to:

    Hi $All
    We’ve created a Github repository for a JSON parser written for Studio 5. Where’s the best place to announce it?
    https://github.com/graemereid/JSON_for_Studio5
    From the ReadMe:
    JSON_for_Studio5
    This library contains an Object class (oJSON) that is intended as a substitute for the built-in OJSON found in Studio 8. It arose from the need to parse and generate JSON in a project for a client that it still running in Studio 5. This is really cool, so if you’re going to pinch it, make sure you acknowledge us ok?
    Usage
    The oJSON object contains the following methods:
    oJSON.$jsontolistorrow(psData[,&psErrorText])
    Parse the JSON array or object in psData and return a row representing the JSON
    IN: psData – JSON to parse, psErrorText – contains the error if parsing fails
    OUT: vrJSON – row representing the JSON array or object, or NULL if parsing fails
    oJSON.$listorrowtojson(prJSON)
    Encodes the row representing the JSON array or object as a character string
    IN: prJSON – row representing the JSON array or object
    OUT: vsData – unformatted JSON
    oJSON.$formatjson(psData)
    Parses the JSON in psData and returns a formatted representation
    IN: psData – JSON to format
    OUT: vsData – formatted JSON or error message if parsing fails
    oJSON.$couldbearray(psData)
    Returns true if psData could be a JSON array because its first character is [
    IN: psData – JSON to parse
    OUT: kTrue if psData could be a JSON array
    oJSON.$couldbeobject(psData)
    Returns true if psData could be a JSON object because its first character is {
    IN: psData – JSON to parse
    OUT: kTrue if psData could be a JSON object
    Note that there are a couple of (hopefully minor) differences between this class and the built-in class in Studio 8. Most of these are for features that we did not need for our project, so feel free to add them if you need them 🙂
    In the Studio 8 version:

    • the $jsontolistorrow method takes an optional third parameter [bAllowArraysOrRows=kFalse]
    • the $listorrowtojson method takes an optional second parameter [iEncoding=kUniTypeUTF8] and third parameter [&cErrorText]
    • there is an additional method $arrayarraytolist(vData[,&cErrorText])
    • there is an additional method $listtoarrayarray(lList[,iEncoding=kUniTypeUTF8,&cErrorText])
    • there is an additional method $objectarraytolist(vData[,&cErrorText])
    • there is an additional method $listtoobjectarray(lList[,iEncoding=kUniTypeUTF8,&cErrorText])

    The parser is somewhat permissive, so it may successfully parse invalid JSON, and it does not handle escaped quotes within string literals. Also, it treats every literal as a string, rather than attempting to determine the type from the context.
    The library also contains a Code class (TestJSON) with sample code to parse, encode, and format JSON.
    Authors
    @graemereid, submitted on behalf of Logical Developments

  • Paul Mulroney Mulroney

    Member
    January 16, 2018 at 12:12 am in reply to:

    Thanks for the feedback Alex – we’ll do that!

  • Paul Mulroney Mulroney

    Member
    January 15, 2018 at 3:29 am in reply to:

    Hi $All,
    We’ve written some code that mirrors the oJSON object in Studio 8, for use in our Studio 5 systems. We believe that this is something that other developers who aren’t using the latest and greatest may find useful.
    It seems that the logical place to put this code is on GitHub, but the first pre-requisite is that you must be using Studio 8.1. It’s kind of a catch-22: if you have Studio 8.1, you don’t need routines to handle JSON, they’re built into Studio 8.
    What’s the best way to share this code with the community?

  • Paul Mulroney Mulroney

    Member
    January 10, 2018 at 6:27 am in reply to:

    Hi Das!
    Good to hear from you. Hope all is well with you. In answer to your questions:
    1. Yes. While code can be executed on the jsClient, you can also execute code on the Omnis server that the jsClient is connected to.
    2. Yes. It’s not the preferred setup – Code Classes are considered to be “not good Object-Oriented design”. That being said, if you’re converting your app to a more modern setup, code classes can be a stepping stone into the Object-Oriented world.
    3. No. No copy/paste from thick client window objects to remote forms. You have to remake your interface using the objects specifically made for the remote form. You could consider writing some code to do the work for you, and create an equivalent of each field in the remote form, but what you find is that the remote forms don’t work quite the same way as a window would. Depending on how your thick-client application works, there could be huge differences between the two.
    4. No. There is a “Background object”, which can be set to be a line, or a circle, rectangle, image etc.
    5. Yes. Keep in mind, unless you’re deploying a “serverless client”, you need an Omnis Server running somewhere that your jsClient connects to. That’s where the externals etc are installed.
    6. I suspect the mailing list 🙂
    Regards,
    Paul.

Page 4 of 4