question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How best to interpret/parse "items" with no "role" or "valType"

See original GitHub issue

I realize this may not be the best place to ask this. If so please redirect me to a more appropriate forum.

My testing of a Scala wrapper failed on (among others) these mocks:

I have realized that all have a schema with the following shape (example based on gl2d_parcoords_select_first_last_enum.json):

                "dimensions": {
                    "items": {
                        "dimension": {
                            "label": {
                                "valType": "string",
                                "role": "info",
                                "editType": "plot",
                                "description": "The shown name of the dimension."
                            },
                            "tickvals": {
                                "valType": "data_array",
                                "editType": "plot",
                                "description": "Sets the values at which ticks on this axis appear.",
                                "role": "data"
                            },
                           "role": "object"
                    },
                    "role": "object"
                },

Looking at the JSON documents, it seems like "items" is a JSON array that contains objects of a specific type (in the example above it would be "dimension"). But the schema does not seem to make this explicit. Trying to work out how to parse this consistently. How should I go about it - can I assume that this is always so?

I may be missing something, but this may be a candidate for another "valOjects". By tagging "items"it would make it easier to parse.

Appreciate any help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolaskruchtencommented, Apr 6, 2020

Anything to do with the schema should be reported here in Plotly.js, as this is where the schema is maintained. The Plotly.py project auto-generates Python code based on this schema, so we can draw lessons from how we do things in Python for your Scala project, but the “single source of truth” for the structure of things is here.

1reaction
nicolaskruchtencommented, Apr 6, 2020

(edited for clarity)

I think that last one is just a quirk in the indicator_attrs mock… you’ll see in the baseline image that this is being ignored I think: https://github.com/plotly/plotly.js/blob/master/test/image/baselines/indicator_attrs.png (there is no blue range between -100 an 100. We should probably fix that mock and update the baseline!

Regarding the interpretation @jonmmease will be able to better speak to how we handle this in Python but yes, in general I think we treat

  "things": { 
    "role": "object",
    "items": { 
      "thing": {
        "role": "object",
        <spec>
      } 
    }
  }

to mean things is an ordered list of thing objects which have the given spec. I think in all cases there is a "role": "object" set there, so it doesn’t seem all that ambiguous to me…

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide To Parsing: Algorithms And Terminology
There are a few ways to define the meaning of parsing. ... is: if a grammar of a language has recursive, or nested,...
Read more >
Understanding Success Criterion 4.1.1 - W3C
The intent of this Success Criterion is to ensure that user agents, including assistive technologies, can accurately interpret and parse content.
Read more >
Parse {“item”=“value”} with java - Stack Overflow
You do understand that all you could do is 1 line of code: String array[] = line.replaceAll("[\\{\\}\"]", "").split(",");. If I'm not ...
Read more >
What is data parsing? - ScrapingBee
Regardless of what type of data parser you choose, a good parser will figure out what information from an HTML string is useful...
Read more >
JavaScript Developers Guide | Parse
There are several ways to put constraints on the objects found by a Parse.Query . You can filter out objects with a particular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found