Skip to content

Transform nested object #33

@chsakell

Description

@chsakell

Is it possible to transform nested objects?
Let's say we have an object with a liveData property which is an object with nested objects...

"liveData": {
   "score": {
      "home": "1",
      "away": "0"
   },
   "clock": {
      "secondsSinceStart": 3792,
      "clockStopped": false
   }
}

.. and we need to tranform it to the following:

"live": {
   "sc": {
      "h": "0",
      "a": "0"
   },
   "t": {
      "s": 3792,
      "st": false
   }
}

So what is the template for livedata object?
I tried the following approach but no luck.

import livedataTemplate from './livedata.template';
let template = "live": livedataTemplate;

livedataTemplate looks like this.

import scoreTemplate from './score.template';
import clockTemplate from './clock.template';

export default {
    "{{livedata}}": {
        "sc": scoreTemplate,
        "t": clockTemplate
    }

.. score / clock templates respectively..

export default {
    "{{score}}": {
        "h": "{{home}}",
        "a": "{{away}}"
    }
}
export default {
    "{{clock}}": {
        "s": "{{secondsSinceStart}}",
        "st": "{{clockStopped}}"
    }
}

what am I doing wrong? any help would be appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions