Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Cannot Import JSON File From the Studio?

2 replies
Last updated: Sep 2, 2020

Seems like I can not import json file from the Studio?
I'd like to use

from the browser.For that I need to provide project id.
It is
. I'd like to keep it there to have only one source of truth.But when I try to import it from my Custom Input Component, I'm getting

Error in ./sanity.json
Syntax error: <path to studio>/sanity.json: Unexpected token, expected ";" (2:8)

  1 | {
> 2 |   "root": true,
    |         ^
I believe sanity does not allow to import json and tries to interpret it like a regular js file.

Is there any solution for such case?

Sep 2, 2020, 2:13 PM

I think

import client from 'part:@sanity/base/client'
will get you the configured client in studio code, so you might not need to read the project id.

Sep 2, 2020, 2:34 PM

Amazing!Thanks man!

Sep 2, 2020, 2:37 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.