Tagged: github omnis.ci json
This topic contains 11 replies, has 3 voices, and was last updated by Paul Mulroney 2 years, 9 months ago.
-
AuthorPosts
-
October 28, 2017 at 8:25 pm #12141
Hi All,
At the Euromnis annual general meeting last week I volunteered to write a step-by-step guide for how to share Omnis libraries on GitHub. I’m pleased to announce that guide is available here:
http://omnis.ci/guides/sharing-omnis-libraries-on-github.html
I wrote a blog post explaining why it’s important for us to share Omnis code on GitHub, but if you want the TL;DR: version, we need several hundred repositories that contain Omnis code in order to register Omnis as an official language with GitHub. Hence, I hope the above guide will be helpful to everyone in the pursuit of that goal.
If you want to read more, here is the post:
http://omnis.ci/github/tutorial/announcement/2017/10/27/a-call-to-arms.html
I’d also like to give a huge thank you to Henk Noppe for writing a second guide on how to contribute to an Omnis library that’s hosted on GitHub, and to Christoph Schwerdtner for beta-testing the guide. You can find Henk’s guide here:
http://omnis.ci/guides/contribute-to-omnis-libraries.html
As a starting metric, there are 2,986 files with a .omh extension and a 1,338 with a .lbs extension on GitHub as of this writing. Not all of these are Omnis code, but I’ll report back periodically with how we’re doing in raising these numbers.
If anyone needs help sharing their library on GitHub, I’m happy to provide it either on this forum, or via direct email.
Thank you in advance for sharing your code!
Alex
November 1, 2017 at 12:28 am #12210Good work Alex! We’re looking at what we can share from our own codebase that other developers would find useful. Hopefully we can put up a few things!
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102November 2, 2017 at 12:56 pm #12236Thank you! I’m very excited to see the interesting and useful code that folks have developed over the years!
January 15, 2018 at 3:29 am #13200Hi $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?
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102January 15, 2018 at 2:13 pm #13205You can absolutely share Studio 5 lbs files on GitHub. The advantage of using Studio 8.1 is that you can also dump the source to readable files, then use git to compare and manage the code. I recommend you:
1. Post the Studio 5 lbs file(s) so others can download and use them
2. Update a local copy of the library to Studio 8.1
3. Export the source from 8.1
4. Include that source with your Studio 5 libraryIf someone wants to offer an enhancement with a pull request, have them do the same. That way you, and others, can compare and see the differences in the exported code. Studio 8.1 doesn’t radically change code from 5, so reviewing the exported 8.1 code should give you a fair evaluation of what’s changed in Studio 5.
January 16, 2018 at 12:12 am #13208Thanks for the feedback Alex – we’ll do that!
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102January 16, 2018 at 3:56 am #13209Hi $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 JSONIN: psData – JSON to parse, psErrorText – contains the error if parsing fails
OUT: vrJSON – row representing the JSON array or object, or NULL if parsing failsoJSON.$listorrowtojson(prJSON)
Encodes the row representing the JSON array or object as a character stringIN: prJSON – row representing the JSON array or object
OUT: vsData – unformatted JSONoJSON.$formatjson(psData)
Parses the JSON in psData and returns a formatted representationIN: psData – JSON to format
OUT: vsData – formatted JSON or error message if parsing failsoJSON.$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 arrayoJSON.$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 objectNote 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
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102January 16, 2018 at 5:50 am #13212Hi $All,
Here’s another one:
https://github.com/pmulroney/ListIntersect_for_Studio5From the ReadMe:
ListIntersectOmnis Lists are powerful constructs that allow us to manipulate data in memory. A common operation is selecting lines in the list, often based on another list. A fairly simple way to do this would be to have two nested loop operations like the following pseudocode:
For vList1.$line from 1 to vList1.$linecount step 1
For vList2.$line from 1 to vList2.$linecount step 1
If vList1.field=vList2.field
Select list line(s) {#L}
End For
End ForFor this code, it executes the inner loop n x m times – where n = list 1 linecount, and m = list 2 linecount. If List 1 or List 2 are large, then you could be executing the inner loop millions of times, and take a significant amount of time to do so.
This is where the $ListIntersect() function comes in. This method has been written so that you only process the smallest list *once*, which results n a significant performance increase.
This is really cool, so if you’re going to pinch it, make sure you acknowledge us ok?
USAGE
oListInterection.$ListIntersect(plList1,plList2,psFieldname,psFieldtype)
IN:- plList1 – the larger of the two lists to process. It can have duplicate values in the column that you’re testing
- plList2 – the smaller of the two lists.
- psFieldname – the column name in the list that you’re comparing again
- psFieldtype – options are Char, Int, Num or Date.
OUT: All lines in list1 that exist in list2 will be selected in list1.
NOTE
Both lists will be sorted by the nominated field name.
The comparison column must be the same name/type in both lists.EXAMPLE
See Example1 for a trivial example of this method in operation. For a given list of cities/states in Australia, only select lines for a number of cities
In our software we use it as part of our search filtering process for some reports.AUTHORS
@pmulroney, submitted on behalf of Logical DevelopmentsContributing
1. Fork this repository
1. Add a branch for your feature
1. Add the feature and perform a new JSON export
1. Submit a pull requestA man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102January 16, 2018 at 11:31 am #13215Hi Paul,
These are excellent! As to your question for announcing, here’s what I put on the omnis.ci site:
- Post under the News form on the Omnis Developer portal
- Email developer@omnis.net with a request to add your library to the Libraries section of the Omnis Developer portal. Be sure to include a link to repository on GitHub and a brief description of what the library does
- Post an announcement to the Omnis Developer List
Thanks again to you and Graeme!
AlexJanuary 22, 2018 at 5:16 pm #13343OK guys. I have added your libraries to the Libraries section on this website:
https://developer.omnis.net/librariesI will promote these on our social media, etc. Excellent work guys – thanks!
January 23, 2018 at 12:08 am #13362Awesome!
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102May 15, 2018 at 2:47 am #15393Here’s another one:
There’s a problem with TCPPing on Studio 5.2, Mac OS Sierra and above – it always returns an error. I’ve created a workaround, and posted the code on GitHub.
NOTE: you don’t need to do this for Studio 8.0 and above, or for Windows/Linux, or for Mac OS before 10.12 (Sierra).
Here’s the link on Github: https://github.com/pmulroney/TCPPing_for_Studio5
A man rushed into the doctor’s office and shouted, “Doctor! I think I’m shrinking!”
The doctor calmly responded, “Now, settle down. You’ll just have to be a little patient.”Paul W. Mulroney
We Don't Do Simple Pty Ltd
ACN 161 009 374
Bentley Western Australia 6102 -
AuthorPosts
You must be logged in to reply to this topic.