Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

escaping quotes in json data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    escaping quotes in json data

    I am starting to use json fields in my Mariadb database and it looks like it will be great in some circumstances, but I have a problem. When I feed that json into an Alpha json function, I have to escape the quotation marks. Easy enough to do by hand in the examples in documentation that only have two quotes, but I have hundreds.

    I tried strtran() but it burps. What is the trick to change " to " everywhere?

    For any of you that are interested, here is what I'm finding:
    So far, we have 1.3 million inspection result records in our tables plus history logs of who made the changes, who did the inspections, the result of QC plus tables of defects found and how they were resolved. With Json, we will still have 1.3 million records, but in a smaller table and without those extra tables. We have two simple text fields in the record, one of which contains stuff like this:
    [{"when":"2017-10-21 1105", "type":"O", "by":"33", "source":"E", "text":"POC approved."},
    {"when":"2017-10-20 0645", "type":"O", "by":"1244", "source":"P", "text":"The orifice was changed to .05 in and is now 99 percent."},

    {"when":"2017-10-12 1533", "type":"O", "by":"33", "source":"E", "text":"The burner is overfired and the design should be reviewed for safe operation."},
    {"when":"2017-10-10 0906", "type":"Q", "by":"3", "source":"Q", "text":"This should be changed to a recommendation"},
    {"when":"2017-10-08 1515", "type":"D", "by":"2,22", "source":"F", "text":"The burner is overfired and must be reduced for safe operation."}]

    So, it contains the date, the evaluation at the time of the entry, who decided it, what department was responsible and what was found. To me, as Deon would say, this is amazing and very cool.
    Pat Bremkamp
    MindKicks Consulting

    #2
    Re: escaping quotes in json data

    For example... what Alpha JSON function are you feeding this array of JSON Objects into?

    Code:
    [{"when":"2017-10-21 1105", "type":"O", "by":"33", "source":"E", "text":"POC approved."},
    {"when":"2017-10-20 0645", "type":"O", "by":"1244", "source":"P", "text":"The orifice was changed to .05 in and is now 99 percent."},
    {"when":"2017-10-12 1533", "type":"O", "by":"33", "source":"E", "text":"The burner is overfired and the design should be reviewed for safe operation."},
    {"when":"2017-10-10 0906", "type":"Q", "by":"3", "source":"Q", "text":"This should be changed to a recommendation"},
    {"when":"2017-10-08 1515", "type":"D", "by":"2,22", "source":"F", "text":"The burner is overfired and must be reduced for safe operation."}]

    Comment


      #3
      Re: escaping quotes in json data

      I've tried a bunch of them, json_parse() and json_validate() for two.

      I tried the jsescapequotes() function and it changed all the quotes to \x22 which gave an "unknown escape character" error.

      I put my json into jslint and it said it was good.
      Pat Bremkamp
      MindKicks Consulting

      Comment


        #4
        Re: escaping quotes in json data

        Using json_parse() for an example, feeding your JSON string into json_parse() produces a dot variable. E.g.

        Code:
        dim myJSON as c = <<%str%
        [{"when":"2017-10-21 1105", "type":"O", "by":"33", "source":"E", "text":"POC approved."},
        {"when":"2017-10-20 0645", "type":"O", "by":"1244", "source":"P", "text":"The orifice was changed to .05 in and is now 99 percent."},
        {"when":"2017-10-12 1533", "type":"O", "by":"33", "source":"E", "text":"The burner is overfired and the design should be reviewed for safe operation."},
        {"when":"2017-10-10 0906", "type":"Q", "by":"3", "source":"Q", "text":"This should be changed to a recommendation"},
        {"when":"2017-10-08 1515", "type":"D", "by":"2,22", "source":"F", "text":"The burner is overfired and must be reduced for safe operation."}]
        %str%
        
        dim dataJSON as p
        
        dataJSON = json_parse(myJSON)
        dataJSON[1] will look like this... {when=2017-10-21 1105,type=O,by=33,source=E,text=POC approved.}
        dataJSON[1].text will have the value POC approved

        dataJSON1.PNGdataJSON2.PNG

        What is it you're wanting to do?

        Comment


          #5
          Re: escaping quotes in json data

          Yes, that is what I want. As far as I can tell, we did exactly the same thing, but I got errors and you got the result I wanted. Magic Fingers!
          Thank you David.
          Pat Bremkamp
          MindKicks Consulting

          Comment


            #6
            Re: escaping quotes in json data

            Pat, were you able to get the results you wanted like David's?

            If not, you might want to compare which AA build version you are using. Also, it could be a difference between doing a full install of AA into a new folder vs. applying just an update patch to existing AA folder.

            I've noticed alpha using JSON object names written without double-quotes. The new standard says to always put the object names in double-quotes and I have been concerned about compatibility issues that might arise in some of Alpha's JSON manipulation functions because of this.

            Comment


              #7
              Re: escaping quotes in json data

              I was using the interactive window. Looks like David was using a function or a script since he was able to use the debugger.
              Pat Bremkamp
              MindKicks Consulting

              Comment


                #8
                Re: escaping quotes in json data

                I am trying to understand what you want to do, not the json part of it, that is simple.
                Do you currently have table(s) that you want to convert to new table with json objects as data?
                or, you already have table(s) with json and want to use it with alpha?
                Last edited by GGandhi; 11-04-2017, 04:57 AM.
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment


                  #9
                  Re: escaping quotes in json data

                  We do safety inspections of industrial gas fired equipment in the oil industry for compliance with national, provincial and local regulations. This might be a food cart in Edmonton, a chemical plant in Calgary or the fire displays at a rock concert. Because of the diversity, there is no standard list of points to check, so we create a list of 200 to 300 questions out of a possible 1500 for each piece of equipment.

                  We currently have a history of over 7000 inspections and 1.3 million questions answered.

                  Collecting the data is the easy part. After that, we need to decide to shut down the equipment, let them continue with warnings about what needs fixing, recommend improvements, or pass the equipment. Some questions are controversial and our engineers discuss them with the owner's or installer's engineers and the Provincial authorities, so we need a history of what was said, who said it and what was the outcome. So, we have child tables and log files that record every change on the equipment and logs of every change to the questions and records of monitoring the fixes to the equipment up to the point of passing. Then if the equipment is changed or moved to a location with different regulations, we need to monitor and approve those also. Each of those other tables also have millions of records.

                  We see json as a way to record that history compactly without all the extra tables. Like a medical chart, we can see the history of the equipment over time, all in one table. This could be a huge improvement.
                  Pat Bremkamp
                  MindKicks Consulting

                  Comment


                    #10
                    Re: escaping quotes in json data

                    excellent. but you want to do it from now on or convert what you have. and where does alpha comes in(your post#1) in your example.
                    (just my two cents, while extra tables are gone, the the data is actually incorporated into a single table and the related entry is kept as attributes or whatever one chooses to call the information as one one of the field)
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                      #11
                      Re: escaping quotes in json data

                      We are just now experimenting and starting to decide. Converting over is a 2018 project. I've created a json version of the 1.3 million record table over in our development area. It was pretty quick to do, and now we are looking at how to collect the data and create the reports. We already use a combination of alpha and stored procedures to collect and massage the data and create our reports, so this new approach will undoubtedly also be a mix alpha and stored procedures. We just have to work out the fastest and most reliable combination.
                      Pat Bremkamp
                      MindKicks Consulting

                      Comment

                      Working...
                      X