Forum

HomeHomeCoreCoreBlue SkyBlue SkyOutput JSON nativelyOutput JSON natively
Previous
 
Next
New Post
1/15/2013 9:44 AM
 

Hi,


It would be great if OWS could emit JSON natively.  Right now a person must run a query, then perform a ton of string concatenation steps to manually build JSON formatted text.  The benefits would be far ranging.  By serializing the dataset in an OWS .dll there would be some performance gains, and less OWS to configure.  As well, there are quite a few JQuery plugins that can accept JSON directly.  Also, a person could develop an API for their web application with relative ease.  Personally I think this has enough benefit to be considered even prior to OWS v3, and hopefully included in the new version as well.


What does everyone think?  Are you building a lot of JSON manually now?  


Thanks

New Post
1/15/2013 11:05 AM
 
I agree...

We currently export XML straight from SQL and consume it via a proxy on the client that turns it into JS objects.

 

It would be nice (great) if we could export JSON from SQL.. but XML is pretty solid in MS SQL.

Brad

New Post
6/16/2013 2:24 PM
 

Hi,


You might try this:


  • Start a new OWS config.  Delete everything except the Region - OnLoad, Region OnRender, and No Query Template.
  • In the Region - OnLoad
  • Add an Assignment action, set the Name to "jsonOutput" (without the quotes), set the type to "assign"
    then add the beginning part of your JSON
  •  Add a Query action, and name it, and add your query
  • Nest an Assignment action under the query, give it the same name as the first one, set the type to "append"
  • Add another Assignment action below the query, not nested., using the same name as the first two, set the type to "append" and wrap up the JSON.  
  • In the Region - OnREnder
  • Addnother Assignment, but set the type to Response.ContentType, leave the name blank and add "text/json" in the value (without the quotes).
  • The last item is your No Query Template, enter your [jsonOutput,Action] in the value.
  • Done

I tried to attach an export of these steps as well but the form won't take it. 



Best regards,
Robert
New Post
6/16/2013 2:26 PM
 
{"Name":"Test - JSON Output Only","recordsPerPage":"0","enableAlphaFilter":"false","enablePageSelection":"false","enableRecordsPerPage":"false","enableCustomPaging":"false","enableExcelExport":false,"enableHide_OnNoQuery":false,"enableHide_OnNoResults":false,"enableAdvancedParsing":true,"enableCompoundIIFConditions":"true","enableQueryDebug":"false","enableQueryDebug_Edit":"false","enableQueryDebug_Admin":"false","enableQueryDebug_Super":"true","enableQueryDebug_Log":false,"enableQueryDebug_ErrorLog":false,"autoRefreshInterval":"","skipRedirectActions":"false","skipSubqueryDebugging":"false","enableAdmin_Edit":true,"enableAdmin_Admin":false,"enableAdmin_Super":false,"enableAJAX":"false","enableAJAXCustomPaging":"false","enableAJAXCustomStatus":"false","enableAJAXManual":"false","includeJavascriptUtilities":"false","includeJavascriptValidation":"false","javascriptOnComplete":"","enableMultipleColumnSorting":"false","ModuleCommunicationMessageType":"","showAll":"true","useExplicitSystemVariables":"false","enabledForcedQuerySplit":"false","searchItems":[],"queryItems":[],"listItems":[],"messageItems":[{"Index":1,"Level":0,"Parameters":{"Name":"OnLoad","RenderType":"0","skipDebug":"False","includeSearch":"False","includeExport":"False","includeImport":"False"},"ActionType":"Action-Region","ChildActions":[{"Index":2,"Level":0,"Parameters":{"Type":"<Action>","Name":"jsonOutput","Value":"{\"users\": [","SkipProcessing":"false","AssignmentType":"0"},"ActionType":"Action-Assignment","ChildActions":[]},{"Index":3,"Level":0,"Parameters":{"Name":"qryUsers","Query":"SELECT TOP(25) UserID\n      ,Username\n      ,FirstName\n      ,LastName\n      ,IsSuperUser\n      ,AffiliateId\n      ,Email\n      ,DisplayName\n      ,UpdatePassword\n      ,LastIPAddress\n      ,IsDeleted\n      ,CreatedByUserID\n      ,CreatedOnDate\n      ,LastModifiedByUserID\n      ,LastModifiedOnDate\n  FROM Users","IsProcess":"false","Connection":"","CacheName":"","CacheTime":"","CacheShared":"false"},"ActionType":"Action-Execute","ChildActions":[{"Index":4,"Level":0,"Parameters":{"Type":"<Action>","Name":"jsonOutput","Value":"{\"user\": {\n    \"UserID\": [UserID]\n    ,\"UserName\": \"[UserName]\"\n    ,\"FirstName\": \"[FirstName]\"\n    ,\"IsSuperUser\": \"[IsSuperUser]\"\n    ,\"AffiliateId\": \"[AffiliateId]\"\n    ,\"Email\": \"[Email]\"\n    ,\"DisplayName\": \"[DisplayName]\"\n    ,\"UpdatePassword\": \"[UpdatePassword]\"\n    ,\"LastIPAddress\": \"[LastIPAddress]\"\n    ,\"IsDeleted\": \"[IsDeleted]\"\n    ,\"CreatedByUserID\": \"[CreatedByUserID]\"\n    ,\"CreatedOnDate\": \"[CreatedOnDate]\"\n    ,\"LastModifiedByUserID\": \"[LastModifiedByUserID]\"\n    ,\"LastModifiedOnDate\": \"[LastModifiedOnDate]\"\n  }\n},","SkipProcessing":"false","AssignmentType":"1"},"ActionType":"Action-Assignment","ChildActions":[]}]},{"Index":5,"Level":0,"Parameters":{"Type":"<Action>","Name":"jsonOutput","Value":"{\"_comment_\" : \"validated at http://jsonlint.com/\"}]}","SkipProcessing":"false","AssignmentType":"1"},"ActionType":"Action-Assignment","ChildActions":[]}]},{"Index":6,"Level":0,"Parameters":{"Name":"OnRender","RenderType":"0","skipDebug":"False","includeSearch":"False","includeExport":"False","includeImport":"False"},"ActionType":"Action-Region","ChildActions":[{"Index":7,"Level":0,"Parameters":{"Type":"CONTENTTYPE","Name":"","Value":"text/json","SkipProcessing":"false","AssignmentType":"0"},"ActionType":"Action-Assignment","ChildActions":[]},{"Index":8,"Level":0,"Parameters":{"Type":"Detail-NoQuery","GroupStatement":"","GroupIndex":"","Value":"[jsonOutput,Action]","Connection":"","Filter":"","CacheTime":"","CacheName":"","CacheShared":"false"},"ActionType":"Template","ChildActions":[]}]}],"query":"","filter":"","customConnection":"","listItem":"","listAItem":"","defaultItem":"","noqueryItem":"","SearchQuery":"","SearchTitle":"","SearchLink":"","SearchAuthor":"","SearchDate":"","SearchKey":"","SearchContent":"","SearchDescription":"","Version":"20","enableAJAXPaging":"false","enableAJAXPageHistory":"false","customAJAXPageHistory":"","disableOpenScript":false,"enableSilverlight":false,"javascriptInclude":[],"ConfigurationID":"13714138-0829-06B4-76BB-18C25063D0C0"}


Best regards,
Robert
New Post
6/16/2013 2:27 PM
 

I tried.



Best regards,
Robert
Previous
 
Next
HomeHomeCoreCoreBlue SkyBlue SkyOutput JSON nativelyOutput JSON natively


 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share Bookmark and Share