JonHMChan / descartes

Descartes | Write CSS in JavaScript
https://descartes.io/slides
MIT License
444 stars 21 forks source link

Not JSON #31

Closed franciscop closed 8 years ago

franciscop commented 8 years ago

Really cool experiment, I tried to do the same the other way around; inserting scripts into CSS. However, I have something to note. This is not JSON:

new Descartes({
  "html": {
    "margin": 0,
    "padding": 0,
    "body": {
      "margin": 0,
      "padding": 0,
      "section": {
        "max-width": "800px"
      }
    }
  }
})

It's just a javascript object (also noted as literal object). It'd be JSON if it was all a big string, but in this way it's just an object. See one explanation and [another](http://stackoverflow.com/a/2904181/938236 %28reason 3%29).

JonHMChan commented 8 years ago

You're right - quite honestly, I was just lazy about my terminology and inconsistent with the copy on the homepage. It's a JS object literal, and not JSON.

jeremykohn commented 8 years ago

How about storing the "object" data in a separate .json file? You could import and JSON.parse() the file as needed. This might improve maintainability by keeping data separate from application logic.

franciscop commented 8 years ago

Yeah but now the question is whether or not the method also accepts a string to convert it to an object with JSON.parse(). But it'd be quite easy to do so and also quite useful.