dcsimg
Page 4 of 4 FirstFirst 1234
Results 121 to 125 of 125

Thread: VB6 - JsonBag, Another JSON Parser/Generator

  1. #121

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,526

    Re: VB6 - JsonBag, Another JSON Parser/Generator

    First, be sure to note that my TreeView example is incomplete.

    You have to consider that both property name values and string type data values can contain characters that are incompatible with an ANSI TreeView control. Any characters outside the printable 7-bit ASCII range can be problematic, even if some ANSI printables might come out acceptably depending on the locale settings when your program gets run.

    So you really need to escape funky characters or at least zap them to ? or some other place-filler symbol.


    As for color-coding formatted JSON goes, no I do not have anything on hand for that.

    But it seems simple enough to copy and hack JsonBag's Property Get JSON() serialization to create a Property Get JSONRTF() or a Property Get JSONHTML() that returns marked up JSON with colors. It is just a matter of doing the necessary busy work.

  2. #122
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,829

    Re: VB6 - JsonBag, Another JSON Parser/Generator

    Quote Originally Posted by k_zeon View Post
    I think a Rich TextBox could be more appropriate for this.

  3. #123
    Addicted Member
    Join Date
    Nov 2011
    Posts
    130

    Re: VB6 - JsonBag, Another JSON Parser/Generator

    Quote Originally Posted by dilettante View Post
    First, be sure to note that my TreeView example is incomplete.

    You have to consider that both property name values and string type data values can contain characters that are incompatible with an ANSI TreeView control. Any characters outside the printable 7-bit ASCII range can be problematic, even if some ANSI printables might come out acceptably depending on the locale settings when your program gets run.

    So you really need to escape funky characters or at least zap them to ? or some other place-filler symbol.


    As for color-coding formatted JSON goes, no I do not have anything on hand for that.

    But it seems simple enough to copy and hack JsonBag's Property Get JSON() serialization to create a Property Get JSONRTF() or a Property Get JSONHTML() that returns marked up JSON with colors. It is just a matter of doing the necessary busy work.
    Hi dilettante. tks for reply. I will look in to hacking the JSON() and see if poss to create JSONRTF.

  4. #124
    Addicted Member
    Join Date
    Nov 2011
    Posts
    130

    Re: VB6 - JsonBag, Another JSON Parser/Generator

    Quote Originally Posted by Eduardo- View Post
    I think a Rich TextBox could be more appropriate for this.
    Hi Eduardo. Yes i have used this before to display VB6 code and works very well. However i dont know how to modify the existing code to take care of Json / Javascript
    as above post , i will see about modifying the JsonBag to create a JsonRTF as that would be quite good as i use JsonBag to show in a textbox and nicely spaced out.
    maybe i can take it a step closer to use a RichtextBox to display data. would be a good addition to JsonBag.

    If i try to create a JsonRTF would i create a string that contains the Json and the richtext code and then apply to the richtextbox
    or once text is on the Richtextbox loop through and colour code the text accordingly.

    I am thinking option one as it goes through the serailisation to add richtext formatting as we go.

    what do you think

    thanks
    Last edited by k_zeon; Mar 6th, 2019 at 08:53 AM.

  5. #125
    New Member
    Join Date
    Apr 2019
    Posts
    1

    Re: VB6 - JsonBag, Another JSON Parser/Generator

    Hi
    I am using JSONBag 2.5 with VB6 to try and create a series of Json messages. I have managed to write working procedures for all the messages bar one. This one needs an array within it. I don't seem to be able to grasp the way to contruct this code. Can somebody give me a few pointers?
    So the complete message should look like this:

    {
    "MaintenanceType": "Preventive",
    "MaintenanceOrderNumber": "MO676578576",
    "MaintenanceJobCode": "MNT113334",
    "Tasks": [
    {
    "Task": "Changed hydraulic fluid in resovoir 1",
    "TaskId": "HYD233432432",
    "Operator": {
    "OperatorIdentifier": "BADGE489435",
    "ActorType": "Human",
    "LastName": "Smith",
    "FirstName": "Joseph",
    "LoginName": "joseph.smith@abcdrepairs.com"
    },
    "ManHoursConsumed": 0.75
    },
    {
    "Task": "Checked torque on main mount bolts",
    "TaskId": "CHK3432434",
    "Operator": {
    "OperatorIdentifier": "UID235434324",
    "ActorType": "Human",
    "LastName": "Smith",
    "FirstName": "Joseph",
    "LoginName": "joseph.smith@abcdrepairs.com"
    },
    "ManHoursConsumed": 0.25
    }
    ]
    }
    and my code looks like this:

    Code:
    '---------------------------------------------------------------------------------------
    ' Method : CFXMaintenancePerformed
    ' Author : Simon Smith
    ' Date   : 07/12/2016
    ' Purpose: Create CFX.ResourcePerformance.MaintenancePerformed message
    ' Updated:  13/12/2018
    '---------------------------------------------------------------------------------------
    Public Sub CFXMaintenancePerformed()
    
        CFXEnvelope                                             ' Add envelope data
        With JB
            ![MessageName] = "CFX.ResourcePerformance.MaintenancePerformed"
            With .AddNewObject("MessageBody")                     ' Add Message Body specifics
                .Item("MaintenanceType") = "Preventive"
                .Item("MaintenanceOrderNumber") = "MO676578576"
                .Item("MaintenanceJobCode") = "MNT113334"
                With .AddNewArray("Tasks")
                    With .AddNewArray()
                        .Item("Task") = "Changed hydraulic fluid in resovoir 1"
                        .Item("TaskId") = "HYD233432432"
                        With .AddNewObject("Operator")
                            .Item("OperatorIdentifier") = "BADGE489435"
                            .Item("ActorType") = "Human"
                            .Item("LastName") = "Smith"
                            .Item("FirstName") = "Joseph"
                            .Item("LoginName") = "joseph.smith@abcdrepairs.com"
                        End With
                        .Item("ManHoursConsumed") = 0.75
                    End With
                    With .AddNewArray()
                        .Item("Task") = "Checked torque on main mount bolts"
                        .Item("TaskId") = "CHK3432434"
                        With .AddNewObject("Operator")
                            .Item("OperatorIdentifier") = "UID235434324"
                            .Item("ActorType") = "Human"
                            .Item("LastName") = "Smith"
                            .Item("FirstName") = "Joseph"
                            .Item("LoginName") = "joseph.smith@abcdrepairs.com"
                        End With
                        .Item("ManHoursConsumed") = "0.25"
                    End With
                End With
            End With
        End With
        SendSmartMessage JB.JSON
    End Sub
    The issue is to do with the array formation I think.

    Thanks Simon

Page 4 of 4 FirstFirst 1234

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width