https://pulumi.com logo
#typescript
Title
# typescript
c

colossal-room-15708

04/08/2020, 10:00 PM
I think I'm way deep in the rabbit hole and I need someone to help me out with this super basic thing... I've got a resource that accepts a JSON.stringify() string. How do I read a json file in the same folder (call it
template.json
) into this property? I tried way too many things now and they all seem way too complex (SO answers usually are).
s

steep-toddler-94095

04/09/2020, 4:55 AM
you can simply
import yourFile from "./yourFile.json"
which will allow you to use it as an (implicitly typed) variable make sure in your tsconfig you have this enabled:
Copy code
{
  "compilerOptions": {
    "resolveJsonModule": true
    ...
c

colossal-room-15708

04/09/2020, 1:14 PM
works like a charm, and was something I've been trying the whole time, but people skipped over the tsconfig
👍 1