Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix json schema #11

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Fix json schema #11

wants to merge 1 commit into from

Conversation

lucemia
Copy link

@lucemia lucemia commented Apr 11, 2020

fix bugs in lottie-web jsonschema and add schema annoiation

usage

python annoate.py [filepath]
will generate a lottie animate schema file for the input filepath

e.g. python annotate.py ..\demo\adrock\data.json

tmp

bugs

  • #/effects/layer -> #/effects/layerIndex
  • #/helpers/testBased -> #/helpers/textBased
  • #/layers/preComp -> #/layers/comp
  • many nm type should be string
  • #/layers/solid ty type should be const
  • missing #/properties/const, copy #/properties/value
  • #/properties/doubleKeyframe -> #/properties/constKeyframed
  • #/shaps/round -> #/shaps/roundedCorners
  • merge https://github.com/guiccbr/lottie-web/tree/fix-jsons fix #/layers/text, #/sources/chars
  • data.json's valueKeyframed value doesn't match schema
  • checkBox -> checkbox
  • Value ->value
  • multiDimensionalKeyframed

NOTE: jsonschema python package not work

the properties key will conflict with jsonschema keywords and #/properties/***

Using $id with $ref

$id also provides a way to refer to subschema without using JSON Pointer. This means you can refer to them by a unique name, rather than by where they appear in the JSON tree.

Reusing the address example above, we can add an $id property to the address schema, and refer to it by that instead.

{
  "$schema": "http://json-schema.org/draft-07/schema#",

  "definitions": {
    "address": {
      "$id": "#address",
      "type": "object",
      "properties": {
        "street_address": { "type": "string" },
        "city":           { "type": "string" },
        "state":          { "type": "string" }
      },
      "required": ["street_address", "city", "state"]
    }
  },

  "type": "object",

  "properties": {
    "billing_address": { "$ref": "#address" },
    "shipping_address": { "$ref": "#address" }
  }
}

Note
This functionality isn’t currently supported by the Python jsonschema library.

@lucemia lucemia requested review from benwu95 and vickyliin April 15, 2020 04:33
@lucemia
Copy link
Author

lucemia commented Apr 15, 2020

bezierIn.x = 1 - infIn / 100;
bezierOut.x = infOut / 100;
break;
case PropertyValueType.SHAPE:
case PropertyValueType.NO_VALUE:
averageSpeed = 1;
infOut = Math.min(100 / lastKey.easeOut.speed, lastKey.easeOut.influence);
infIn = Math.min(100 / key.easeIn.speed, key.easeIn.influence);
bezierIn.x = 1 - infIn / 100;
bezierOut.x = infOut / 100;
break;
case PropertyValueType.ThreeD:
case PropertyValueType.TwoD:
case PropertyValueType.OneD:
case PropertyValueType.COLOR:
bezierIn.x = [];
bezierOut.x = [];
kLen = key.easeIn.length;
for (k = 0; k < kLen; k += 1) {

valueKeyframe's i property can be array or object at the same time

Copy link
Collaborator

@vickyliin vickyliin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我 local 試跑會發生
FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/effects/checkbox.json'
正常嗎~?

@lucemia
Copy link
Author

lucemia commented Apr 15, 2020

我 local 試跑會發生
FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/effects/checkbox.json'
正常嗎~?

已修正..
原來 git 會忽略掉檔名大小寫變動

@vickyliin
Copy link
Collaborator

我 local 試跑會發生
FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/effects/checkbox.json'
正常嗎~?

已修正..
原來 git 會忽略掉檔名大小寫變動

結果我還有 FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/properties/Value.json'
但是我把它改成大寫之後變成 FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/properties/value.json'

@lucemia
Copy link
Author

lucemia commented Apr 15, 2020

我 local 試跑會發生
FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/effects/checkbox.json'
正常嗎~?

已修正..
原來 git 會忽略掉檔名大小寫變動

結果我還有 FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/properties/Value.json'
但是我把它改成大寫之後變成 FileNotFoundError: [Errno 2] No such file or directory: '../docs/json/properties/value.json'

有的地方是用 Value 有的地方是用 value 現在統一成 #/properties/value

Copy link
Collaborator

@vickyliin vickyliin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

應該還沒有要全部支援?
不知道是 bug 還是 feature 的:

  • transform (ks) 跟 transform 的第一層 property 沒有 description

已經可以正常生出 schema 了,但目前看過去還有缺一些:

  • shape layer 的 shapes/bounds
  • comp layer 的 w/h
  • transform 的 r 好像資料裡跟定義的不太一樣,資料裡好幾個 property 都是在 array 裡

scripts/annoate.py Outdated Show resolved Hide resolved
@lucemia
Copy link
Author

lucemia commented Apr 15, 2020

應該還沒有要全部支援?
不知道是 bug 還是 feature 的:

  • transform (ks) 跟 transform 的第一層 property 沒有 description

已經可以正常生出 schema 了,但目前看過去還有缺一些:

  • shape layer 的 shapes/bounds
  • comp layer 的 w/h
  • transform 的 r 好像資料裡跟定義的不太一樣,資料裡好幾個 property 都是在 array 裡

很多要修的.. 不知道為什麼會錯那麼多

@lucemia
Copy link
Author

lucemia commented Apr 15, 2020

 },
    "i": {
      "description": "Bezier curve interpolation in value.",
      "extended_name": "In Value",
      "properties": {
        "x": {
          "description": "bezier x axis. Array of numbers.",
          "extended_name": "X axis",
          "type": "array"
        },
        "y": {
          "description": "bezier y axis. Array of numbers.",
          "extended_name": "Y axis",
          "type": "array"
        }
      },
      "type": "object"
    },
{'i': {'x': 0.833, 'y': 0.833}, 'o': {'x': 0.167, 'y': 0.167}, 'n': '0p833_0p833_0p167_0p167', 't': 339, 's': [35.965, -1024.97, 0], 'e': [35.965, -104.97, 0], 'to': [0, 153.33332824707, 0], 'ti': [0, -153.33332824707, 0]}

@lucemia
Copy link
Author

lucemia commented Apr 22, 2020

結論

  • data.json 裡的資料並非是 After Effect 中的 Raw Data,
    是經過 Bodymovin 轉換, Player & Extension 間的共用格式
  • 目前的 docs/json 中 JSONSchema 應該不是最新的
  • 光看 After Effect 文件沒辦法確認 data.json 格式正確,有些修正不過來

@benwu95 benwu95 removed their request for review May 12, 2020 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants