-
Posts
1,981 -
Joined
-
Last visited
-
Days Won
183
Content Type
Profiles
Forums
Downloads
Gallery
Everything posted by drjdpowell
-
The To-JSON behaviour was copied from the previous LAVA-JSON library. That library had the reverse operation, but it only worked if one provided same-named attributes in the default value. As you point out, this is because we need to know what type to convert the JSON to. Personally, I found this kind of useless, as the whole point of attributes is to have unknown items of unknown type. I had also developed "subJSON" for exactly this use case, and never use Variant Attributes at all. So it kind of got stuck in limbo. I note that the newer Set and Map support doesn't run into this issue, as Sets and Maps have Type. Options: Leave as is, not really supporting Variant Attributes Deprecate the current To-JSON support and fully not support Attributes at all Save Type in the JSON somehow (I don't like this) Use limited JSON types when converting from JSON: String, Float, Boolean As in LAVA-JSON, but using (4) as a fall back if type not supplied Added later: see https://bitbucket.org/drjdpowell/jsontext/issues/39/support-json-to-variant-when-no-datatype where it was proposed to do (4), I think.
-
That is a case that needs (at least) a better error. Try the path $."" By using the quotes, the name is any JSON string, and can thus handle any name. The unquoted form is for convenience and can't handle all edge cases. BTW, what JSON are you feeding in to that node. It has to be an Object if you want to insert at $.""
-
Note: latest version supports comments. https://forums.ni.com/t5/JDP-Science-Tools/BETA-version-of-JSONtext-1-6/m-p/4146235#M39
-
Ah, this can be illustrated with this image: JSONtext does not follow the common error rule of returning default value on any error. Instead, it returns best-efforts, with only sub-elements that produce errors being returned as the supplied default. Here it is only the "B" element, requested as a Float but a String in the JSON, that is returned as default (as explained in the error message). Thus we are doing the Variant-to-Data even on error, in order to get this partial conversion of JSON to Data.
-
This was originally a method in the early prototype API of JSONtext (pre public release), which is why it has a "default" input. However, I used this (now private) method internally whenever a LabVIEW type is stored as a JSON string (should really have made a separate method). In such use, I found a problem of needing a better description of the error if conversion failed, and for that I needed the actual LVtype. This is not really how I would design it from scratch, but it happened incrementally.
-
Git detatched head. All of a sudden this makes sense!
drjdpowell replied to Neil Pate's topic in Source Code Control
"Git Branches aren't branches; they're just tags pointing to commits" is the first thing one needs to understand about Git. -
The various Insert functions, like the subVI on the Right, don't support Pretty Print. I suggest you try Reformat, which can Pretty Print the resulting JSON. Or in the latest 1.6.5 version, just released, try the new "Pretty Print" function, which is faster and supports Comments.
-
Not sure I understand. The data type is just an array in a cluster; it's not actually protected in any way. It makes a copy if you want an ordered array, but not if you want to just access the circular buffer itself. That you can do by "unbundle".
-
I did a Circular Buffer using VIMs, so I'm pretty sure one can get the same basic functionality, though i suspect there is advanced Xnode stuff that VIMs can't do.
-
Terminology is an aid to communication among multiple people, so I'll stick with how I have seen "SEQ" generally used, unless I see multiple people use it differently. There are lots of terms that are not exactly literal; your "watchdogs" aren't actually canines, for example, but I understood the software concept you actually meant.
-
Oh, sorry, I misread it. Your timing out on an Enqueue of a full Queue, while I have always built "watchdogs" using timeout on Dequeuing from an empty Queue.. In your case you do need to set a single element so as to define "full".
-
I had a look at your watchdog example. I note that, in my mind, "SEQ" stands for a pattern of using of a one-element Queue like a DVR, rather than any use of a Queue with only one element. I changed your example to use a Queue of 10 elements, and it ran fine, so the single-element nature is not a meaningful characteristic. Even in cases where I use Queues that have to have one element, such as my "Future Tokens" in "Messenger Library", I don't think of them as "SEQs", even though they are literally single-element queues.
-
Ah, you guys are talking about use of SEQs now, after DVRs were available. I'm thinking about before DVRs existed, where SEQs were often used to get DVR-like functionality. Most of that use of SEQs will have been replaced by DVRs now.
-
It is my, perhaps mistaken, belief that SEQs were quite often used to fill the gap before DVRs were invented. I'm sure I saw several examples in other people's APIs, and I used them mostly that way. I've used the "back pressure" of a queue, too, but then it's an N-element queue, were N might be set at one, but doesn't have to be, unlike the DVR-like use case where it must be single-element.
-
Using JSONText to parse a poorly formatted JSON string
drjdpowell replied to jed's topic in LabVIEW General
All the Tools Network libraries are supposed to have help documentation of some kind. At some point, they insisted I do it. -
I don't use DQMH myself, but some suggestions: Re #1 and using the timeout: you don't need to use a fixed timeout; you can write some small subVI that calculates the time remaining till the next scheduled read. For example, if teh last Read was at 98700 ms, the next read should happen at 98800 ms. If it is now 98712 ms, then the subVI can output a 88 ms timeout. If a message is handled, and the time is now 98798 ms, then the subVI will calculate a timeout of 2 ms. You would code in logic of what to do if it is after the scheduled time (either do anyway, or skip). Re #2: you could have the higher-level Module A send a message to C containing the User Event of B's Broadcast. Then C can listen to B, without directly referencing it. B and C would need to agree on the datatype of the User Event, but would not otherwise be coupled. A is doing the coupling, but without handling all the messages.
-
Using JSONText to parse a poorly formatted JSON string
drjdpowell replied to jed's topic in LabVIEW General
There is a page on Path notation too: -
Using JSONText to parse a poorly formatted JSON string
drjdpowell replied to jed's topic in LabVIEW General
Did you look at the detailed help on teh JSONtext VIs? They should all contain links to further documentation pages (or you can go to Help>>JDP Science>>JSONtext...). The "<JSON> tags" page explains: -
Using JSONText to parse a poorly formatted JSON string
drjdpowell replied to jed's topic in LabVIEW General
Just a comment, but I have noticed that people very often deal with JSON by looking for the "monster cluster" that completely converts the JSON into a monolithic LabVIEW structure. I suggest people think a bit more modularly in terms of "subJSON". The first question I would ask you if I were working with you on your actual project is why do you need (at this code level, at least) to convert your variables from their perfectly reasonable JSON format to an array of clusters? -
Using JSONText to parse a poorly formatted JSON string
drjdpowell replied to jed's topic in LabVIEW General
-
Malleable Buffer (seeing what VIMs can do)
drjdpowell replied to drjdpowell's topic in Code In-Development
I've put 0.4 on VIPM.io. -
Unflatten From JSON breaks on NUL characters (LabVIEW 2017+)
drjdpowell replied to LogMAN's topic in LabVIEW Bugs
I reported that in 2018: CAR 605085. I don't think they are planning on fixing it. Must use C strings under the hood.