# Viewing JSON field in workspace

**URL:** <https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426>\
**Category:** Help me!\
**Created:** [June 22, 2023, 11:04am UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426 "2023-06-22T11:04:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zero](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zero/32/479_2.png) [@Zero](https://community.forestadmin.com/u/Zero)\
**Post date:** [June 22, 2023, 11:04am UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/1 "2023-06-22T11:04:26Z")

</div>

## Feature(s) impacted

Workspace

## Observed behavior

We have created a smart field that’s a JSON and we also have a model field that’s a JSON as well we were trying to bring this into our workspace but no matter what we try it’s out outputting the JSON.

Is it even possible to show the JSON in the workspace?

## Expected behavior

Field outputs JSON

## Failure Logs

## Context

- Project name: …
- Team name: …
- Environment name: …
- Agent (forest package) name & version: …
- Database type: …
- Recent changes made on your end if any: …

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2023, 12:38pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/3 "2023-06-22T12:38:46Z")

</div>

Hey @Zero,

I did not understood at all your issue sorry 😅.  
Are you trying to display a field inside your `json`. For example if you have the following json

```json
{
  name: 'test',
  power: 'me'
}

```

You want to be able to display the `name` ?

---

<div class="post-metadata">

**Author:** ![Zero](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zero/32/479_2.png) [@Zero](https://community.forestadmin.com/u/Zero)\
**Post date:** [June 22, 2023, 12:57pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/4 "2023-06-22T12:57:59Z")

</div>

Hi sorry for not being clear but that’s correct I’ll like to access certain information inside the json

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2023, 1:05pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/5 "2023-06-22T13:05:50Z")

</div>

Okey so I need to know which agent (forest package) and version you are using please 🙏

---

<div class="post-metadata">

**Author:** ![Zero](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zero/32/479_2.png) [@Zero](https://community.forestadmin.com/u/Zero)\
**Post date:** [June 22, 2023, 1:17pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/6 "2023-06-22T13:17:37Z")

</div>

Attached the relevant information below, thank you

```
"liana": "forest-express-sequelize",
"liana_version": "9.3.1",
"stack": {
  "database_type": "postgres",
  "engine": "nodejs",
  "engine_version": "16.16.0",
  "orm_version": "5.15.2"

```

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2023, 1:18pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/7 "2023-06-22T13:18:35Z")

</div>

Okey let me write you a quick script that will ease your work 🙂

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2023, 1:25pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/8 "2023-06-22T13:25:38Z")

</div>

```javascript
// This will help you define your JSON field correctly 
const transformToSchemaType = (object) => {
  if (Array.isArray(object)) {
    return object.map(transformToSchemaType);
  }
  if (typeof object === "object") {
    return {
      fields: Object.keys(object).map((key) => {
        return {
          field: key,
          type: transformToSchemaType(object[key]),
        };
    }),
    };
  }
  return object.name;
};

// Then define your smart field
collection('myCollection', {
  fields: [{
    field: 'myJsonAsRecord',
    // Replace this type with the definition of what's inside your JSON field
    type: transformToSchemaType({
      environmentId: Number,
      enabled: Boolean,
      collections: [
        {
          collectionName: String,
          browseEnabled: Boolean,
          addEnabled: Boolean,
          editEnabled: Boolean,
          deleteEnabled: Boolean,
          exportEnabled: Boolean,
        },
      ],
    }),
    get(myCollectionRecord) {
      return myCollectionRecord.myRealJsonField;
    },
    set(myCollectionRecord, newValue) {
      myCollectionRecord.myRealJsonField = newValue;
    }
  }]
})

```

---

<div class="post-metadata">

**Author:** ![Zero](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/zero/32/479_2.png) [@Zero](https://community.forestadmin.com/u/Zero)\
**Post date:** [June 22, 2023, 1:51pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/9 "2023-06-22T13:51:17Z")

</div>

Hi thank you just tested it this work’s if I see it in the details but once I add the field to a workspace and select a record it doesn’t output any information

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2023, 2:17pm UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/10 "2023-06-22T14:17:01Z")

</div>

Could you send me a video where you show me the configuration of your workspace and then showing when selecting a record that nothing is displayed ? You can send it in private if there is any sensitive data 😉

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 23, 2023, 6:19am UTC](https://community.forestadmin.com/t/viewing-json-field-in-workspace/6426/11 "2023-06-23T06:19:49Z")

</div>

It’s certainly a misconfiguration on your agent if you have nothing displayed. Could you share with me the code of your smart field and the name of your json field please 🙏
