Jump to content

camow7

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by camow7

  1. On 1/31/2020 at 11:25 PM, drjdpowell said:

    A possibly better option is to replace your string/integer values with JSON strings, which is LabVIEW strings with <JSON> at the start of the name.  So "<JSON>Comment" rather than "Comment".   JSONtext will happily parse out the value into your cluster as JSON, then when you actually need your value you can convert it to string/integer, with appropriate handling if it is null or throws an error.

    This method, by the way, is also how to handle JSON that has variable structure.

    Tested this and it worked well. Had no idea you could add the <JSON> tag to parse complex data types like dictionaries. Super handy. This looks likes it's solved my problems. Thanks!

  2. @drjdpowell Also if you go through and set the comment fields to empty strings, the next parsing error hit is this:
     

    Quote

    Error 1 occurred at JSONtext.lvlib:JSON text to Variant.vi:4410003

    Possible reason(s):

    Cannot Get as integer: null


    Complete call chain:
         JSONtext.lvlib:JSON text to Variant.vi:4410003
         JSONtext.lvlib:JSON text to Variant.vi:4410002
         JSON Parsing Error.vi

    This is replicated using the same VI shared above by first setting the comment keys to actual strings

  3. I'm trying to parse this JSON data:
     

    {
      "id":"fb66aaec-f713-424c-ba04-386d0986fb12",
      "planId":"4c7cbe9c-ba67-4d8b-b731-32d3de0de700",
      "name":"AJ3",
      "redrillOfHoleId":null,
      "design":{
        "angle":0.0,
        "bearing":4.376555,
        "comment":null,
        "decks":[
          {
            "number":1,
            "horizon":25.0,
            "length":5.0,
            "productId":"f3fb75ac-1065-4d9c-bd6a-fdf01c34837b",
            "weight":0.0,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":2,
            "horizon":20.0,
            "length":5.0,
            "productId":"5800171c-e16e-48e7-9431-ac9b88f4852f",
            "weight":441.786469,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":3,
            "horizon":15.0,
            "length":5.0,
            "productId":"f3fb75ac-1065-4d9c-bd6a-fdf01c34837b",
            "weight":0.0,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":4,
            "horizon":10.0,
            "length":5.0,
            "productId":"0fa2dd6d-6b0c-4bfd-998b-e0b50ee64481",
            "weight":353.429169,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":5,
            "horizon":5.0,
            "length":5.0,
            "productId":"f3fb75ac-1065-4d9c-bd6a-fdf01c34837b",
            "weight":0.0,
            "isVariable":true,
            "isBackfill":false
          },
          {
            "number":6,
            "horizon":0.0,
            "length":5.0,
            "productId":"5800171c-e16e-48e7-9431-ac9b88f4852f",
            "weight":441.786469,
            "isVariable":false,
            "isBackfill":false
          }
        ],
        "diameter":300.0,
        "length":30.0,
        "x":-194.97681394419092,
        "y":67.241148799992772,
        "z":0.0,
        "whenCreated":"2020-01-28T01:51:43.4065706Z",
        "whenUpdated":"2020-01-28T01:51:43.4065706Z"
      },
      "adjustedDesign":{
        "angle":0.0,
        "bearing":4.376555,
        "comment":null,
        "decks":[
          {
            "number":1,
            "horizon":25.0,
            "length":5.0,
            "productId":"0fa2dd6d-6b0c-4bfd-998b-e0b50ee64481",
            "weight":353.429,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":2,
            "horizon":20.0,
            "length":5.0,
            "productId":"f3fb75ac-1065-4d9c-bd6a-fdf01c34837b",
            "weight":0.0,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":3,
            "horizon":15.0,
            "length":5.0,
            "productId":"5800171c-e16e-48e7-9431-ac9b88f4852f",
            "weight":441.786,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":4,
            "horizon":10.0,
            "length":5.0,
            "productId":"f3fb75ac-1065-4d9c-bd6a-fdf01c34837b",
            "weight":0.0,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":5,
            "horizon":5.0,
            "length":5.0,
            "productId":"0fa2dd6d-6b0c-4bfd-998b-e0b50ee64481",
            "weight":353.429,
            "isVariable":false,
            "isBackfill":false
          },
          {
            "number":6,
            "horizon":0.0,
            "length":5.0,
            "productId":"5800171c-e16e-48e7-9431-ac9b88f4852f",
            "weight":441.786,
            "isVariable":false,
            "isBackfill":false
          }
        ],
        "diameter":300.0,
        "length":30.0,
        "x":-194.97681394419092,
        "y":67.241148799992772,
        "z":0.0,
        "whenCreated":"2020-01-28T02:04:07.6143372Z"
      },
      "actual":{
        "angle":null,
        "bearing":null,
        "calculatedDecks":[],
        "comment":null,
        "depthToWater":null,
        "diameter":null,
        "expectedDeckCount":null,
        "length":null,
        "accessories":[],
        "measuredDecks":[],
        "notDrilled":false,
        "userName":null,
        "x":null,
        "y":null,
        "z":null
      },
      "drillAdjustedDesign":null,
      "drillActual":null,
      "holeType":"Hole type 1",
      "materialType":null,
      "isDeleted":false,
      "isNonDesignedHole":false,
      "allowTruncatedDesign":false,
      "disableChangeDesignRules":false,
      "scaleDepthOfBurial":null,
      "strataIntercepts":{},
      "tags":["drilling_designed","loading_designed"],
      "whenCreated":"2020-01-28T01:51:43.4065706Z",
      "whenUpdated":"2020-01-28T01:51:43.4065706Z"
    }

    But am currently getting this error:
     

    Quote

    JSONtext.lvlib:JSON text to Variant.vi:4410001<ERR>
    State: Parser Error
    Near: ':nu'
    in '"2020-01-28T02:04:07.6143372Z"},"actual":{"angle":null,"bearing":null,"calculatedDecks":[],"comment":null,"depthToWater":null,"diameter":null,"expectedDeckCount":null,"length":null,"accessories":[],"me'


    <b>Complete call chain:</b>
         JSONtext.lvlib:JSON text to Variant.vi:4410001
         JSONtext.lvlib:JSON text to Variant.vi:4410003
         Parse Hole JSON.vi

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.