Export from Sketch App to JSON - json

I want to be able to export Layer Names and properties from Sketch to JSON format. I think I can figure out how to pull the info I need from Sketch, but I haven't started to code anything, because I haven't been able to find any info about this export issue.
I'm wondering if anyone can help confirm that Sketch can only export their supported formats or if export to JSON is possible. I don't want to dive into this project only to find out that I can't end up with a JSON file.

I have been trying to work with this as well, and it turns out there are a few ways to get access to a JSON file in sketch.
use the npm package sketch2json
Turns out that if you unzip the .sketch file, there is a JSON file hiding inside.
unzip sketch-header.sketch
This creates a folder called 'pages' with the .json file inside. To get the 'Layer Names', you can just read/serialize the .json file into a string, and then the path to collect the layer names is
const obj = JSON.parse(fileString);
object.layers.forEach((layer) => {
console.log(layer.name);
});

If you rename the .sketch extension file to .zip extension file you will see as many JSON files as pages your sketch document has inside a folder called "Pages". Also some BMP previews images and other JSON related to user and document information.

Related

How can I use any json or array or any js file in .testcaferc.json?

I have created one file .testcaferc.json that contains all configuration information like browser name, specs, timeouts etc. I want to fetch the configuration data from file so that I have to change the information at only one place
I want to store all these information in single file, I tried, js, json and array. But I can not import all above format files in my .testcaferc.json, when I press Alt+F8 I see the error "Expected a JSON object, array or literal"
Is there any way I can import json, array or js data in .testcaferc.json?
Thanks in advance!!
The JSON format doesn't support any import directives. The TestCafe configuration file (.testcaferc.json) is a simple JSON file. So, the TestCafe configuration file doesn't support such functionality.
To achieve your goal, you can transform the existing .testcaferc.json file before test running: load data from various sources and add/replace values for the appropriate data fields.
Also, there is a suggestion in the TestCafe GitHub repository, which will make your scenario easier to implement. Track it to be notified about its progress.

Load data from JSON file in assets with NUXT.js

Suppose I have assets/data/geo/regions.json file in my NUXT.js project folders structure. How can I read data from this file into my project?
I have tried axios but I don't know what URL will have this file, I have tried all possible URLs. What is the better solution to do that? Maybe better to hold JSON files in static folder?
Thanks!
If the regions.json file won't change, you can easily put it in the static folder.
Then the url will be /data/geo/regions.json
See this question on the nuxt issues page
You can import JSON files with import data from 'data.json' and use the data property straight in your component.
You may want to use "require" instead of "import" if you planning to load data within the loop.
jsons = ["json_one","json_two"]
jsons_readed = []
// In the loop
file = require(`./assets/data/geo/${jsons[i]}`)
jsons_readed.push(file)
Then I think you can use jsons_readed to access objects.
You can use Nuxt Content for that:
Empower your NuxtJS application with #nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML, XML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.
The basics are as easy as the following line. That will load the regions.json file, parse it, and store its content in the content variable. See Nuxt Content's documentation for more information about it.
const content = await this.$content('regions').fetch()
Alternatively you can read our blog post about
Using Nuxt Content with a JSON File. It describes how to extend existing pages with JSON content but also how to dynamically generate pages based on it.
Disclaimer: I work at FrontAid CMS.

Include JSON file to build/output directory without import

Maybe the title is a bit strange, but I can't seem to find anything about on google.
Question: I have a folder that only contains .ts files and .json files.. Typescript compiles the .ts files and puts it into a separate directory (not as a bundle, just the directory structure 'as-is').
Src /
Workers /
[ModuleA.ts, ModuleA.json],
[ModuleB.ts, ModuleB.json],
[MobuleC.ts, ModuleC.json]
Most of the time I can just require('*.json') and the JSON file will be also placed in to build directory.
But now I have a situation, where importing the JSON will make no sense, because the JSON file gets updated every few seconds and I read the file with fs.readFile('*.json'), so I also don't want it floating around in the v8 cache (through require)
So how do I 'include' a JSON/None-Typescript file into the build, that is not explicitly being importing by either require or import?
For now I just used gulp to copy every .json file in the src folder over to the the respective dist/** folder.
But still find it strange typescript doesn't have something included for it..
Maybe you should checkout --resolveJsonModule, it's a newer feature of typescript.

Reading files with Node.js from input file type selector

I am trying to select files using input file type and then upload them to dropbox using the dropbox Core API or saving it to a local folder using Node.JS readFile and writeFile methods. The problem is that most of these methods require the file path and all I have is the name of the file that is stored in the File object array and for what I have read browsers do not allow to get the full path for security reasons. I don't know how to go about this, can anyone help me solve this? Thanks!!

3d models -> JSON for WebGL/Three JS

So I have tried to use the three.js editor to convert an .obj file to JSON. When I click export Geometry, though, it doesn't do anything...
http://mrdoob.github.io/three.js/editor/
When I export the scene, though, I get a whole bunch of numbers like so:
"2,1615,1614,1671,1672,1615,3683,3563,3682,3684,3567,57,1615,1672,1673,1616,1615,1672,1673,1616,3685,3567,3684,3686,3570,57,1616,1673,1674,1617,1616,1673,1674,1617,3687,3570,3686,3688,3573,57,1617,1674,1675,1618,1617,1674,1675,1618,3689,3573,3688,3690,3575,57,1618,1675,1676,1619,1618,1675,1676,1619,3691,3575,3690,3692,3577,57,1619,1676,1677,1620,1619,1676,1677,1620,3693,3577,3692,3694,3579,57,1620,1677,1678,1621,1620,1677,1678,1621,3695,3579,3694,3696,3581,57,1624,1679,1680,1625,1624,1679,1680,1625,3697,3587,3698,3698,3587,57,1625,1680,1681,1626,1625,1680,1681,1626,3699,3589,3700,3701,3590,57,1626,1681,1682,1627,1626,1681,1682,1627,3702,3590,3701,3703,3592,57,1627,1682,1683,1628,1627,1682,1683,1628,3704,3592,3703,3705,3594,57,1628,1683,1684,1629,1628,1683,1684,1629,3706,3594,3705,3707,3596,57,1629,1684,1685,1630,1629,1684,1685,1630,3708,3596,3707,3709,3598,57,1630,1685,1686,1631,1630,1685,1686,1631,3710,3598,3709,3711,3600,57,1631,1686,1687,1632,1631,1686,1687,1632,3712,3600,3711,3713,3602,57,1632,1687,1688,1633,1632,1687,1688,1633,3714,3602,3713,3715,3604,57,1633,1688,1689,1634,1633,1688,1689,1634,3716,3604,3715,3717,3606,57,1634,1689,1690,1635,1634,1689,1690,1635,3718,3608,3719,3720,3609,57,1635,1690,1691,1636,1635,1690,1691,1636,3721,3609,3720,3722,3611,57,1636,1691,1692,1637,1636,1691,1692,1637,3723,3611,3722,3724,3613,57,1637,1692,1693,1638,1637,1692,1693,1638,3725,3613,3724,3726,3615,57,1638,1693,1694,1639,1638,1693,1694,1639,3727,3615,3726,3728,3617,57,1639,1694,1695,1640,1639,1694,1695,1640,3729,3617,3728,3730,3619,57,1640,1695,169"
Is this the content of the JSON file I'm trying to look for? If so, do I just save it as nameofmodel.json?
Yes. That's the content of the json file. And yes, you just need to save that into a nameofmodel.json file.