0

So, I've got a json that has a handful of initial values, but as a user story I need to allow adjustments per point/object rather than at the top.

{"properties":{
  "p1":{},
  "p2":{},
  "pollInterval":{},
  "contents":{
    "anyOf":[{
      "properties":{
        ...
        },{

        ...
        }

    }]
  }
}

Here I want to require that if pollInterval is not in the initial properties, it has to be required in either of the anyOf properties blocks. I have the pollInterval definition of both anyOf blocks, though not they are not strictly required like some of the other data. I am just unsure of where to put it. Currently, I have it below the anyOf block as

if":{
        "not":{
            "properties":{
                "pollInterval":{}
            }
        }
    },
    "then":{
        "required":
        {
            
        }
    },

But it doesn't seem to force the pollInterval if I remove pollInterval from the top. How can I fix this?

3
  • 1
    Why has this been tagged as c++ related?
    – G.M.
    Commented Jul 8 at 20:05
  • 1
    And why has this been tagged as embedded related? Please find some more relevant tags. Also, you seem to be trying to use JSON as some kind of general purpose programming language with control flow operators. This seems.... unusual, to me. This is not how JSON is normally used. Commented Jul 8 at 20:54
  • I'm aware of that, however this is the schema for a modbus dataprovider which I am working on. Ideally I would have designed it differently but it was already mostly build when it was passed down to me.
    – AC2199
    Commented Jul 8 at 21:37

0

Browse other questions tagged or ask your own question.