Query to JSON

http://labs.adobe.com/technologies/spry/samples/utils/query2xml.html
It is easier to have the server create the XML from a database on the fly,but I need a lightweight solution.
I think JSON is better-suited for Ajax-style Spry web applications.
Are there any easy ways to convert MySQL query to JSON dataset?

I've got error message:
Failed to retrieve data set (ds1) for spry:repeat
==
PHP code
==
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry/">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dochi-spry json dataset</title>
<script type="text/javascript" src="../SpryAssets/SpryData.js"></script>
<script type="text/javascript" src="../SpryAssets/SpryJSONDataSet.js"></script>
<script type="text/javascript">
    var ds1 = new Spry.Data.JSONDataSet("list_json.js");
</script>
</head>
<body>
<div class="liveSample" spry:region="ds1">
    Values from array: <span spry:repeatchildren="ds1">{idno}({username}) </span>
</div>
</body>
</html>
==
list_json.js
==
    idno: "1",
    username: "test" 

Similar Messages

  • BUG: Incorrect data returned with JSON and CF8

    I don't know if this is a bug, but I am trying to create a
    JSONDataSet that will call a cfc which returns a query in json
    format. However, I have a problem with a column datatype
    varchar(20), for which some rows contains numbers as the value
    (01,02,03,...etc) but when the dataset is returned, the value for
    this column comes as (1.0,2.0,3.0,...etc)
    HELP!!!
    This is my code...
    var dsCities = new
    Spry.Data.JSONDataSet("/remoting/remotegeodataservice.cfc?method=getgeodata&countrycode=u s&featureclass=a&queryformat=column&returnformat=json",
    {path:"DATA", pathIsObjectOfArrays:true});

    I just dumped the dataset like this...
    <div spry:region="dsStates">
    <ul style="margin:0; padding:0;">
    <li spry:repeat="dsStates">{ADMINCODE1} -
    {ASCIINAME}</li>
    </ul>
    </div>
    For Australia this is my result dumped:
    * 1 - Australian Capital Territory
    * 0 - Heard Island and McDonald Islands (general)
    * 3 - Northern Territory
    * 2 - State of New South Wales
    * 4 - State of Queensland
    * 5 - State of South Australia
    * 6 - State of Tasmania
    * 7 - State of Victoria
    * 8 - State of Western Australia

  • Hirarchical JSON Queries on Twitter Data Stream

    Hi,
    The ability to query hierarchical JSON data, and the Azure Table Storage output option are great additions to Stream Analytics.
    I'm currently experimenting with querying into data streams from Twitter.
    Stuff like this works fine:
    -- Get statistics for location
    select
    min (id) as Id,
    [user].location as Location,
    count([user].location) as Total,
    avg([user].followers_count) as AvgFollowers,
    avg([user].favourites_count) as AvgFavourites,
    avg([user].friends_count) as AvgFriends,
    avg([user].listed_count) as AvgListed
    from tweetstream
    where [user].location is not null and [user].location != ''
    group by [user].location, TumblingWindow (minute, 1)
    having Total > 10
    -- Get number of tweets by name
    select [user].screen_name, count (id) as Tweets
    from tweetstream
    group by [user].screen_name, TumblingWindow (minute, 1)
    having Tweets > 1
    -- Select based on text in tweet
    select text
    from tweetstream
    where text like '%food%'
    What I am having issues with is repeating data, such as selecting the hashtags from a tweet.
    There can be zero or more hashtags in a tweet, the JSON looks like this:
    "created_at":"Fri Nov 28 21:42:41 +0000 2014",
    "id":538447914268639232,
    // Deleted
    "entities":
    "hashtags":[
    "text":"fall",
    "indices":[33,38]
    "text":"confessionsofaprchic",
    "indices":[39,60]
    "trends":[],
    "urls":[],
    "user_mentions":[],
    "symbols":[]
    // Deleted
    Is there a way to select the hashtags for a tweet?
    If not, is it something that will be possible in the future?
    Regards,
    Alan
    Free e-book: Windows Azure Service Bus Developer Guide.

    Today you can't access contents of the array in the query. We will be extending query language to allow flattening of arrays for further processing.
    For example, in your scenario, you will be able to transform rows with tweets containing array of hashtags into multiple rows with individual hashtags.
    This should be available soon.

  • $.ajax(): what is the difference between calling a transaction and Xacute query?

    I can call either:
    $.ajax({
         type: "GET",
         url: "/XMII/Illuminator?QueryTemplate=somePathToXacute/someXacute&Content-Type=text/xml&Params...",
         dataType: "xml",
         success: function (result) {...}
    $.ajax({
         type: "GET",
         url: "/XMII/Runner?Transaction=somePathToTransaction/someTran&Content-Type=text/xml&Params...&OutputParameter=outXML",
         dataType: "xml",
         success: function (result) {...}
    When I call an Xacute query, the first execution works, but the second doesn't. I figured out that I have to add "cache:false" and then it is okay. If I use a transaction instead of Xacute query, it works with or without cache. Why is that? Transactions are not cached? Only Xacute queries?
    What is the cost difference in time if I call directly a transaction, instead of an Xacute query? What is the advantage to call an Xacute at all?
    Thx

    Hi Tibor,
    These points should clarify your doubts:
    1. Transactions are not cached but queries are.
    2. Advantage of using Xacute query is that the Illuminator service used to call Xacute query supports JSON from MII 14.0. Use content-type as text/json in the URL. But the restriction is that the transaction should return the XML in MII Rowsets-Rowset format.
    3. Though both the calls would take almost time(I think) but you should call transaction directly( no need to wrap it with Xacute query if not required).
    Regards,
    Rohit Negi.

  • Returning JSON to CF/jQuery

    CF page:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="jquery-1.6.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(e) {              
         $.getJSON('loaddata.cfm',function(data){
         $("#div1").html(data);
    </script>
    </head>
    <body>
    <div id="div1" style="background-color:tan; height:70px; width:450px;"></div>
    </body>
    </html>
    loaddata.cfm
    <cfquery datasource="pubs" name="jquerytest">
         Select * from jquery
    </cfquery>
    <cfoutput>#serializejson(jquerytest)#</cfoutput>
    loaddata.cfm is displaying {"COLUMNS":["ID","TITLE","CONTENT"],"DATA":[[1,"Dave","test content 1"],[2,"Bob","test content 2"],[3,"Jesse","test content 3"]]}
    I'm having an issue returning this CF query in JSON format. It's available but I'm not sure what format/structure jQuery expects, what I have isn't outputting any data. My
    $("#div1").html(data);
    isn't displaying any data.

    Bear in mind that jQuery doesn't expect a particular format, you have the ability to retreive any JSON object and do something with it.  That being said most JSON services return a collection of key/value pairs, a serialized CFQUERY resultset is a little different.  A query object contains a COLUMNS and DATA property.  In the case of the DATA property each item is an array with one item per field. The COLUMNS property contains an array of column names.
    You should also set the HTTP header of the loaddata.cfm page to identify the contents as JSON, you can add the following just before the CFOUTPUT tag on that page:
    <cfcontent type="application/json" reset="yes">
    Here is a quick sample of JavaScript to get you started, you should be able to copy and paste this to replace the JS block in the sample you posted.
    <script type="text/javascript">
    $(document).ready(function(e) {             
         $.getJSON('loaddata.cfm',function(data){
            //build HTML text to be displayed
            var txt = "<ul>";
            //the DATA property will contain one array for each row in your result set
            for(var i = 0; i < data.DATA.length; i++)
                txt = txt + "<li>" + data.DATA[i][1] + "</li>";  //add the second item in the array, to the string to be output
            txt = txt + "</ul>";
            $("#div1").append(txt);  //add the new HTML block to the DOM. 
    </script>
    I recommend that you take a look at:
    Ray Camden's blog, which contains many jQuery related articles:
    http://www.coldfusionjedi.com/index.cfm/2007/9/20/Quick-and-Dirty-JSONQuery-Example
    The tutorials section of the jQuery site:
    http://docs.jquery.com/Tutorials

  • Want to access RESTful Services through Java Program

    We are trying to access RESTful Services exposed by Oracle database cloud through our Java code, with authentication enabled for a particular user.
    Till now, we have completed below steps:
    1) We have a working account with Oracle database cloud (Username – xxx.xxx)
    2) We log in using the credentials for above account, and navigate to Oracle Apex ? SQL Workshop ? RESTful Services
    3) We create a new “RESTful Service Module” by filling out the details as below:
         Name:                                  SampleTest 
         URI Prefix:                            test
         URI Template:                       /getallemp
         Pagination Size:                    25 (kept to default)
         Required Privilege:                 TestGroupPrivilege
         Resource Handler Details:
                    Method:              GET
                    Source Type:      Query
                    Format:               JSON
                    Source:               select * from emp
    After creating the above module and testing it, it works fine and the data is retrieved in JSON successfully.
    The resulting URL for above RESTful Service Module is: https://<HOST_URL>/apex/test/getallemp
    Note that “TestGroupPrivilege” is a privilege assigned to the user group “RESTful Services” and the user “xxx.xxx” is a member of “RESTful Services” user group.
    4) We are unable to call the RESTful services from Java program. We are passing username and password in request header as basic authentication. But, we are getting: Error 500--Internal Server Error
    5) If we change the “Required Privilege” to default i.e. no privileges present on the module, we can get the response through Java code and everything works perfectly fine.
    Please suggest us in: How to access RESTful Services through Java code by passing user credentials in HTTP header for authentication. Also let us know if we have to do any settings through Apex, in case we are missing any.
    Message was edited by: NeerajGirolkar
    - When we are logging in to Oracle cloud on browser and execute the Oracle cloud RESTful service in another tab of same browser, we are able to get the result. But when executed the same RESTful service from a different browser or java program we get internal server error.
    - After investigation, we found that when user logs in to oracle database cloud, a cookie is set in browser with name s “OAMAuthnCookie_cstest-domo.db.us1.oraclecloudapps.com:443” and value as some random token. This cookie is passed in the subsequent requests to the RESTful Service calls when using same browser and as a result, we are able to get the results
    - In the Java program, we copied the same cookie with random token in the HTTP Request header and we got the proper response from REST APIs.
    - It seems that this cookie is created by an Oracle Middleware tool/server called as OAM – Oracle Accounts Manager, which sends the authentication token after successful authentication and creates the cookie.
    - We found that the cookie that OAM creates on authentication is exactly in the same format i.e. ‘OAMAuthnCookie_cstest-domo.db.us1.oraclecloudapps.com:443’. So, we are guessing that Oracle cloud uses OAM for authentication. Please refer to following link for same : http://docs.oracle.com/cd/E14571_01/doc.1111/e15478/sso.htm
    Can anyone please suggest:
    1.     How to provide authentication to Oracle Cloud REST APIs from java program?
    2.     How to pass the username and password in Java code to OAM (or how to communicate with OAM using Java) so that we can receive the unique token from OAM. We can use the token in the further requests? 3.     Also in Oracle cloud white papers , it is mentioned that they support OAuth2.0. But we didn’t find any URLs for same. Can anyone please confirm?
    Thanks
    ~ Neeraj Girolkar

    Hi Nilesh,
    We tried to connect to Oracle Cloud Database using the way you suggested above, but unfortunately it is not working as well.
    Can you let us know the authentication process with Oracle Cloud Database? We found in documentation that it uses OAM (Oracle Access Manager) for authentication. Can you tell us a bit about that? That will be extremely helpful.
    Thanks,
    - Neeraj

  • Next reference in pagination does not follow the correct scheme

    How do I force the "next" reference in the json output to use the correct scheme?   it seems to always revert to "http://" resulting in a 301 redirect that client javascripts have trouble handling.
    i.e. I create a single GET method (no parameters),  source type "Query", format "JSON".
    Requires Secure Acecss: YES
    Pagination size: 5
    query: "select * from user_objects"
    press test,  https://example.com/ords/workspace/modulename/test
    see the pagination reference http instead of https
    {"next":{"$ref":"http://example.com/ords/workspace/modulename/test?page=1"},"items":
    How can I make it show the correct scheme?
    Thank you
    Oli

    I would also like to know if It's possible to rewrite the resulting url
    So let's say if I have rewritten /ords/workspace/modulename/ to /mn/ in my front-end.  Could I get the "next" pagination to list  {"next":{"$ref":"https://example.com/mn/test?page=1"},"items":   instead of the full path.

  • Reader Hive query - Cannot deserialize the current JSON object

    Hi all,
    I am trying to run a Reader module in MLStudio with a Hive query but it fails with Error 0000: Internal error.
    In the output log I see this error:
    [ModuleOutput] DllModuleHost Error: 1 : Program::Main encountered fatal exception: Microsoft.Analytics.Exceptions.ErrorMapping+ModuleException: Error 0000: Internal error ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Newtonsoft.Json.Linq.JToken' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    [ModuleOutput] To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    [ModuleOutput] Path 'FileStatus.length', line 3, position 14.
    But I don't see any configuration to change any JSON settings.
    What am I doing wrong? Can anyone help me?
    Thanks,
    Csaba
    PS: Using the Hive Editor I can select from my table without any problems.

    Can you let us know if you are still encountering this error? It doesn't look the error is due to user error.

  • "Json is undefined" error message when running web query in excel

    Hello,
                Im trying to run a web query to import flight price data from ryanair into excel.
    I get a "Json is undefined" error message whenever i  run the web query.
    I also get a message from Ryanair saying my browser is out of date even though I have Internet Explorer 11.
    Ive added screenshots so i hope they display correctly.
    Can anyone help with this.
    Thank you

    Hi,
    Did this issue only occur with the Ryanair website or other websites( Such as Microsoft websites)?
    If this issue only occur with Ryanair website, this issue might be caused by the website script error, please see the below image ( I could reproduce your issue with this URL):
    We might be able to query the data with this site.
    If your web query can't access the other site, please try the below workaround.
    Copy the code in to VBE and set the website URL.
    Sub Web_Query()
    Sheets.Add
    Dim myURL
    myURL = "url;http://www.xxxxxx.com"
    With ActiveSheet.QueryTables.Add(Connection:=myURL, Destination:=Range("A1"))
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = False 'True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "1" '"1,2,3,4"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    End Sub
    Hope it's helpful.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Looping through json object in a query string

    Hi
    I have a json object in my query string and would like to loop through it, do i convert it to an array, or a map, so that i can loop through it?
    I get the object from the url which looks like this:
    {"CREATEDBYNAME":"TEST_ADMIN","FIRSTNAME":"John","TYPEID":"1900000000"}
    I would then like to loop through it so that i can make a string that would look like:
    "CREATEDBYNAME" = "TEST_ADMIN" AND "FIRSTNAME" = "John" AND "TYPEID"="1900000000"
    I want to use a loop because there can be up to 15 options in the json object. and the if statement would just not do.
    Plz help.

    What you can do with that object, I can't tell you because I don't know what it can or can't do. What's its API? Where does it come from?

  • Most simple query on Event Hub stream (json) constantly gives Data Conversion Errors

    Hello all,
    Been playing with ASA in December and didn't have any issues, my queries kept working and outputted the data as needed.  However, since January, I created a new demo, where I now constantly get Data Conversion errors.  The scenario is described
    below, but I have the following questions:
    Where can I get detailed information on the data conversion errors?  I don't get any point now (not in the operation logs and not in the table storage of my diagnostic storage account)
    What could be wrong in my scenario and could be causing these issues
    The scenario I have implemented is the following:
    My local devices send EventData objects, serialized through Json.Net to an Event Hub with 32 partitions.
    I define my query input as Event Hub Stream and define the data as json/utf8.  I give it the name TelemetryReadings
    Then I write my query as SELECT * FROM TelemetryReadings
    In the output, I create an output on blob with CSV/UTF8 encoding
    After that, I start the job
    The result is an empty blob container (no output written) and tons of data conversion errors in the monitoring graph.  What should I do to get this solved?
    Thanks
    Sam Vanhoutte - CTO Codit - VTS-P BizTalk - Windows Azure Integration: www.integrationcloud.eu

    So, apparently the issue was related to the incoming objects, I had.  I was sending unsupported data types (boolean and Dictionary).  I changed my code to remove these from the json and that worked out well.  There was a change that got deployed
    that (instead of marking the unsupported fields as null, they were throwing an exception).  That's why things worked earlier.
    So, it had to do with the limitation that I mentioned in my earlier comment:
    https://github.com/Azure/azure-content/blob/master/articles/stream-analytics-limitations.md
    Unsupported type conversions result in NULL values
    Any event vales with type conversions not supported in the Data Types section of Azure Stream Analytics Query Language
    Reference will result in a NULL value. In this preview release no error logging is in place for these conversion exceptions.
    I am creating a blog post on this one
    Sam Vanhoutte - CTO Codit - VTS-P BizTalk - Windows Azure Integration: www.integrationcloud.eu

  • ColdFusion Query and Structures to JSON

    Hello All,
    Please, excuse my self-promotion.
    If you are trying to integrate Spry JSON with ColdFusion then
    try
    toJSON.cfc.
    Hope it helps you.

    Almost there! 
    If I do select -expandproperty results then I just get
    count
      470
    (The data has changed from the above example from 295 page views to 470).
    I don't get any of the other data, which are the % of page views for each browser. 
    However, if I do select -expandproperty performanceStats then I just get
    fileReadCount      : 3
    inspectedCount     : 562
    matchCount         : 470
    processCount       : 3
    fileProcessingTime : 2
    mergeTime          : 0
    ioTime             : 2
    wallClockTime      : 7
    fullCacheHits      : 1
    partialCacheHits   : 0
    cacheMisses        : 0
    cacheSkipped       : 2
    maxInspectedCount  : 297
    minInspectedCount  : 24
    Which appears to be the complete set from the original JSON output. The same is true of metadata:
    eventTypes      : {PageView}
    eventType       : PageView
    openEnded       : True
    beginTime       : 2015-02-09T13:17:14Z
    endTime         : 2015-02-10T13:17:14Z
    beginTimeMillis : 1423487834145
    endTimeMillis   : 1423574234145
    rawSince        : 1 DAYS AGO
    rawUntil        : `now`
    rawCompareWith  :
    guid            : 3c4d61b1-4413-2bd6-ff0f-cf11ed32b687
    routerGuid      : c7cef9c4-c84e-b1a5-618e-5f729be666d3
    contents        : {@{function=alias; alias=Total Page Views; contents=}, @{function=alias; alias=IE; contents=},
                      @{function=alias; alias=Chrome; contents=}, @{function=alias; alias=Firefox; contents=}}
    It's frustrating that it only appears to be these values that are not displaying. 

  • Unable to show Unicode Data in Oracle RESTful Service JSON

    Hi Everyone.
    I have stored unicode data in Oracle database and when i retrieve in sql query it is showing the same. But when i retrieve the data in json using oracle RESTful web service (GET), it bringing with unknown character as shown below.
    next: {},$ref: "http://000.00.00.00:8085/ords/mobile/sch/loginm/?user=SURESH&pwd=123&page=1"
    items: [
    uri: {},$ref: "http://000.00.00.00:8085/ords/mobile/sch/loginm/41"
    stud_id: 41,
    stud_code: "1001",
    stud_name: "அபà¯&#141;தà¯&#129;லà¯&#141; ஜபà¯&#141;பாரà¯&#141;"
    My Database Setup as below:
    SQL> SELECT name,value$ FROM sys.props$;
    NAME                                                          VALUE$
    DICT.BASE                                                  2
    DEFAULT_TEMP_TABLESPACE               TEMP
    DEFAULT_PERMANENT_TABLESPACE     USERS
    DEFAULT_EDITION                                   ORA$BASE
    Flashback Timestamp TimeZone                    GMT
    TDE_MASTER_KEY_ID
    DBTIMEZONE                                        -07:00
    DST_UPGRADE_STATE                         NONE
    DST_PRIMARY_TT_VERSION               11
    DST_SECONDARY_TT_VERSION          0
    DEFAULT_TBS_TYPE                              SMALLFILE
    NLS_LANGUAGE                              AMERICAN
    NLS_TERRITORY                                   AMERICA
    NLS_CURRENCY                                   $
    NLS_ISO_CURRENCY                         AMERICA
    NLS_NUMERIC_CHARACTERS               .,
    NLS_CHARACTERSET                         AL32UTF8
    NLS_CALENDAR                                   GREGORIAN
    NLS_DATE_FORMAT                              DD-MON-RR
    NLS_DATE_LANGUAGE                         AMERICAN
    NLS_SORT                                        BINARY
    NLS_TIME_FORMAT                         HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT               DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT               HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT          DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY                    $
    NLS_COMP                                   BINARY
    NLS_LENGTH_SEMANTICS          BYTE
    NLS_NCHAR_CONV_EXCP          FALSE
    NLS_NCHAR_CHARACTERSET          AL16UTF16
    NLS_RDBMS_VERSION               11.2.0.1.0
    GLOBAL_DB_NAME                    MOBILE
    EXPORT_VIEWS_VERSION   
    SQL> select DECODE(parameter, 'NLS_CHARACTERSET', 'CHARACTER SET',
      2  'NLS_LANGUAGE', 'LANGUAGE',
      3  'NLS_TERRITORY', 'TERRITORY') name,
      4  value from v$nls_parameters
      5  WHERE parameter IN ( 'NLS_CHARACTERSET', 'NLS_LANGUAGE', 'NLS_TERRITORY');
    NAME          VALUE
    LANGUAGE      AMERICAN
    TERRITORY     AMERICA
    CHARACTER SET AL32UTF8
              8
    WORKLOAD_CAPTURE_MODE    
    WORKLOAD_REPLAY_MODE
    Awaiting you solution.
    -- Abdul Jabbar

    Kumar,
    Ftping the PG.xml to mds folder will not help the page to goto MDS directory
    You have to import the file using xmlimporter
    I understand you have done the import, but it is not success.
    Could you please post what is the script you used to import the PG.xml
    and once you run what was the output you have got.
    May be you can refer the URL for the scripts
    http://apps2fusion.com/at/61-kv/331-oa-framework-scripts
    With regards,
    Kali.
    OSSI.

  • Using OLAP as a data source and create a JSON object

    Hi All,
    I have a question.
    I am working on an hospital assessment project which is being developed using AngularJs and MVC WEBAPI. We are using "HIGHCHARTS" for developing the required dashboards and charts by providing JSON objects which are developed using  MVC WEB-API
    (from normal SQL procedures). 
    Problem is raised when we are trying to build a chart using a table with around 1.2 million records. we are facing severe performance issue while generating the data set. Now, Here is my question "Can
    we generate a JSON object using an SSAS cube accessed using MVC"? If it can be done please help me out with some valuable procedure that can be done.
    Thanks In Advance.
    Regards
    Sunil Kumar 
    Please mark as answer if it is helpful. Thank You

    Hi,
    Here is another way of doing it using MDX code. I do not know whether this helps you but... Following MDX query produces the Sales Amount per Sub Category.
    SELECT {[Measures].[Sales Amount]} ON COLUMNS,
    NON EMPTY{[Product].[Subcategory].[Subcategory].MEMBERS} ON ROWS
    FROM [Adventure Works]
    Following MDX generates the Output As JSON object array.
    WITH MEMBER [Measures].[JSON Object_] AS "{""ProductSubCategories"":[" + Chr(13) +
    GENERATE
    NONEMPTY
    [Product].[Subcategory].[Subcategory].MEMBERS,
    [Measures].[Sales Amount]
    ), Space(10) + "{""SubCategoryName"":""" + [Product].[Subcategory].CurrentMember.Member_Name + """, ""SalesAmount"":""" + CStr([Measures].[Sales Amount]) + """}," + Chr(13)
    MEMBER [Measures].[JSON Object] AS LEFT([Measures].[JSON Object_], LEN([Measures].[JSON Object_]) -2) + Chr(13) + "]}"
    SELECT {[Measures].[JSON Object]} ON COLUMNS
    FROM
    SELECT {[Measures].[Sales Amount]} ON COLUMNS
    FROM [Adventure Works]
    WHERE {([Product].[Subcategory].[Subcategory].MEMBERS)}
    Following is the JSON Object OutPut of the above query.
    {"ProductSubCategories":[
    {"SubCategoryName":"Bib-Shorts", "SalesAmount":"166739.7086"},
    {"SubCategoryName":"Bike Racks", "SalesAmount":"237096.156"},
    {"SubCategoryName":"Bike Stands", "SalesAmount":"39591"},
    {"SubCategoryName":"Bottles and Cages", "SalesAmount":"64274.793600001"},
    {"SubCategoryName":"Bottom Brackets", "SalesAmount":"51826.374"},
    {"SubCategoryName":"Brakes", "SalesAmount":"66018.711"},
    {"SubCategoryName":"Caps", "SalesAmount":"51229.4461000002"},
    {"SubCategoryName":"Chains", "SalesAmount":"9377.7102"},
    {"SubCategoryName":"Cleaners", "SalesAmount":"18406.9725"},
    {"SubCategoryName":"Cranksets", "SalesAmount":"203942.6182"},
    {"SubCategoryName":"Derailleurs", "SalesAmount":"70209.4958"},
    {"SubCategoryName":"Fenders", "SalesAmount":"46619.5799999995"},
    {"SubCategoryName":"Forks", "SalesAmount":"77931.6896"},
    {"SubCategoryName":"Gloves", "SalesAmount":"242795.874200003"},
    {"SubCategoryName":"Handlebars", "SalesAmount":"170591.3209"},
    {"SubCategoryName":"Headsets", "SalesAmount":"60942.1984"},
    {"SubCategoryName":"Helmets", "SalesAmount":"484048.532299996"},
    {"SubCategoryName":"Hydration Packs", "SalesAmount":"105826.4185"},
    {"SubCategoryName":"Jerseys", "SalesAmount":"752259.388399975"},
    {"SubCategoryName":"Locks", "SalesAmount":"16225.22"},
    {"SubCategoryName":"Mountain Bikes", "SalesAmount":"36445443.9409015"},
    {"SubCategoryName":"Mountain Frames", "SalesAmount":"4713672.1469"},
    {"SubCategoryName":"Pedals", "SalesAmount":"147483.9098"},
    {"SubCategoryName":"Pumps", "SalesAmount":"13514.6873"},
    {"SubCategoryName":"Road Bikes", "SalesAmount":"43878790.9970001"},
    {"SubCategoryName":"Road Frames", "SalesAmount":"3849853.3438"},
    {"SubCategoryName":"Saddles", "SalesAmount":"55829.3882"},
    {"SubCategoryName":"Shorts", "SalesAmount":"413522.526999996"},
    {"SubCategoryName":"Socks", "SalesAmount":"29745.1280999999"},
    {"SubCategoryName":"Tights", "SalesAmount":"201833.006"},
    {"SubCategoryName":"Tires and Tubes", "SalesAmount":"246454.527600005"},
    {"SubCategoryName":"Touring Bikes", "SalesAmount":"14296291.2698"},
    {"SubCategoryName":"Touring Frames", "SalesAmount":"1642327.6862"},
    {"SubCategoryName":"Vests", "SalesAmount":"259488.3707"},
    {"SubCategoryName":"Wheels", "SalesAmount":"679070.065399999"}
    Best regards...
    Chandima Lakmal Fonseka

  • How to fix a problem with the order of strings in a JSON response for a CFHTTP request?

    Good morning, guys! (It's 10:50 a.m. in Brazil)
    First of all, I'm still new at CF and my questions may seem too much silly and my English's not the best, so, please be patient with me. hehe
    Well, I'm accessing a link via CFHTTP that gives me a JSON response. I'm not familiar with JSON yet, so I'm working it as a string and using string functions (Find,RemoveChars,Replace,etc), but it happens to me that I'm receiving a certain kind of order of the strings list from the JSON when I access it directly from the browser and other kind of order totally different when I access it from the CFHTTP.
    I only figured it out because I was working at home with my code and there everything went just fine as expected. Then I brought to my job to develop a little bit more as soon as I get a free time and here my code doesn't work anymore. When I took a look at the JSON by a CFOUTPUT, I realized the strings were in a different order.
    Does anyone know why is it happening?
    Link to the JSON: http://sigmine.dnpm.gov.br/ArcGIS/rest/services/extra/dados_dnpm/MapServer/0/query?text=83 0620/2012&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelInter sects&where=&returnGeometry=true&outSR=&outFields=FID,Shape,PROCESSO,ID,NUMERO,ANO,AREA_HA ,FASE,ULT_EVENTO,NOME,SUBS,USO,UF&f=pjson
    Basic code simplified to find out that the order of strings were coming different when access by CFHTTP:
    <cfhttp url="#URLAbove#" method="get" result="DadosDoDNPM" charset="utf-8" timeout="10000" />
    <cfset DadosJSON = deserializeJSON(DadosDoDNPM.FileContent) />
    <cfif arrayLen(DadosJSON.features)>
        <cfset CodigoFonteJSON = ToString(serialize(DadosJSON.features)) />   
        <cfoutput> #CodigoFonteJSON# </cfoutput>
    </cfif>
    Is there a way to fix it and to make my code work everywhere?
    If it matters, I use Railo at home and at my job.
    Since now, I thank you.

    When you deserialize JSON data, ColdFusion converts it into native structures and arrays (roughly equivalent to JavaScript objects and arrays).  In ColdFusion, structures are unordered (that is, they don't maintain keys in any particular ordered sequence).
    This really shouldn't be a problem though, at least not if you just want to work with the data contained in the deserialized JSON structure.  So DadosJSON should be a native ColdFusion structure, and you can interact with it like any other structure in ColdFusion.  In fact, you should not have to re-serialize it at all unless you need to send it to an external application using JSON.
    Why are you reserializing the data?  And why use serialize() instead of serializeJSON()?
    -Carl V.

Maybe you are looking for

  • Help needed in recovering 2 threaded db

    Here we go, I had this working while ago, I have taken a backup of a db, full backup, all successful, this backup had 2 threads. Now the recovery. I recovered the controlfile, then recoevered the database like below, SET UNTIL SEQUENCE 3543 thread 2;

  • Hyperlink to open a file in a new window

    I have been trying to format the hyperlink to a file so it opens on a new window. iWeb allows us to check the box 'open in new window' only for links to external pages; when we insert a link to a file, I realize the app uploads the file to the websit

  • Adobe form translations

    Hi, I have translated adobe form from English to French, however when i execute function module by passing language as 'FR' it is still showing in English only. what could be the reason?? and also when i open the same form in DE language i don't see

  • Droplet does not show cluster

    I created a cluster in Qmaster (which I confirmed does work). I then created a droplet for a particular setting. When I hit submit in the droplet, the cluster does not show up as an option. I do have compressor open at the same time, to rule out the

  • Boot Camp Assistant Cannot Write USB

    I have a 2012 MBP non retina and I was trying to dual boot.  Every time I get to the part where it wants to copy the windows files to my USB it copies all of it (i'm checking the space used on disk utility) then an error pops up saying the USB could