# Complex nested json data to dgraph

**URL:** <https://discuss.dgraph.io/t/complex-nested-json-data-to-dgraph/19084>\
**Category:** Dgraph\
**Tags:** dgraph, pydgraph\
**Created:** [November 27, 2023, 8:19am UTC](https://discuss.dgraph.io/t/complex-nested-json-data-to-dgraph/19084 "2023-11-27T08:19:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jegaths](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jegaths/32/10839_2.png) [@jegaths](https://discuss.dgraph.io/u/jegaths)\
**Post date:** [November 27, 2023, 8:19am UTC](https://discuss.dgraph.io/t/complex-nested-json-data-to-dgraph/19084/1 "2023-11-27T08:19:57Z")

</div>

Hi, I am new to dgraph and graph database. Basically, I have to insert a JSON data to dgraph. The JSON I have is very complex and a little bit dynamic.

The data I am having is an SBOM report. Please find the sample below

{  
“SchemaVersion”: 2,  
“ArtifactName”: “dagflow-app:latest”,  
“ArtifactType”: “container\_image”,  
“Metadata”: {  
“OS”: {  
“Family”: “debian”,  
“Name”: “12.1”  
},  
“ImageID”: “sha256:346f866546896ea789c5c2fa6e86210082a83e620948dc2c52aa66835759ac4e”,  
“DiffIDs”: [  
“sha256:7c85cfa30cb11b7606c0ee84c713a8f6c9faad7cb7ba92f1f33ba36d4731cc82”,  
“sha256:f6589095d5b5a4933db1a75edc905d20570c9f6e5dbebd9a7c39a8eef81bb3fd”,  
“sha256:a981dddd4c650efa96d82013fba1d1189cf4648cd1e766b34120b32af9ce8a06”,  
“sha256:01d6cdeac53917b874d5adac862ab90dcf22489b7914611a1bde7c84db0a99ae”,  
“sha256:c26432533a6af2f6f59d50aba5f76f2b61c2e0088c7e01b5d2a8708b6cb9ef08”,  
“sha256:950807b8113029e596ecd31900481c81d112069c2c644b9376b52d4f38080c9b”,  
“sha256:8e61b2657a8166cc9e7166f9af2165295c60fec29501f3b19c7a502ca912bf3a”,  
“sha256:9f64fe0537e89e159915c38bd700531a9bb6f21a6442b5a22040c4af6bf9f26b”,  
“sha256:504957b5bc380781991e584c4dec22a4851b340da66efbcb48f1821e5dd5b7bb”,  
“sha256:2f5d5ec1305274b3d5bc105edd9dfc87c49038e4f1956f3c89f8755c6008830b”,  
“sha256:d1f91d6c5c8c3c3dd737516e440462bd54de1f79cea4975ad918a988e4ea912f”,  
“sha256:2d661f5b9b0947e36d4cce9f4af907d76e8d21ca7b23ec13f5a72e29c310d535”,  
“sha256:eb8eeef061d2bf930b1cf7bd1db6d1211be664905979524e5604a619423d8d5f”,  
“sha256:dcfaefd67cfb108707cc35ba2c4a072cd70c69c6df7b8c31315529d5f7d03d42”,  
“sha256:661f27320a54eae390a7f00515b4fe43447d3eda0bd4672bb633bdb5bb180fea”,  
“sha256:7ed390f141a295fc8c91e0d4dd1aba2974d9ff55d8bc92f6e53ecfae3923e910”,  
“sha256:32c61845a69a3e01d4a8e5f1128513572b676168215a6f2755e791a28ed884a8”  
],  
“RepoTags”: [  
“dagflow-app:latest”  
],  
“ImageConfig”: {  
“architecture”: “amd64”,  
“created”: “2023-10-11T16:56:23.471034971+05:30”,  
“history”: [  
{  
“created”: “2023-09-20T04:55:26Z”,  
“created\_by”: "\_bin\_sh -c #(nop) ADD file:ce04d6a354feaef93795269c859f36667fce9efda23c61b37d7060263b66ed4e in \_ "  
},  
{  
“created”: “2023-09-20T04:55:26Z”,  
“created\_by”: “\_bin\_sh -c #(nop) CMD ["bash"]”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-09-20T09:20:42Z”,  
“created\_by”: “\_bin\_sh -c set -eux; \tapt-get update; \tapt-get install -y --no-install-recommends \t\tca-certificates \t\tcurl \t\tgnupg \t\tnetbase \t\tsq \t\twget \t; \trm -rf _var\_lib\_apt\_lists__"  
},  
{  
“created”: “2023-09-20T09:21:02Z”,  
“created\_by”: "\_bin\_sh -c apt-get update && apt-get install -y --no-install-recommends \t\tgit \t\tmercurial \t\topenssh-client \t\tsubversion \t\t\t\tprocps \t&& rm -rf var\_lib\_apt\_lists_”  
},  
{  
“created”: “2023-09-20T09:21:58Z”,  
“created\_by”: “\_bin\_sh -c set -ex; \tapt-get update; \tapt-get install -y --no-install-recommends \t\tautoconf \t\tautomake \t\tbzip2 \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\timagemagick \t\tlibbz2-dev \t\tlibc6-dev \t\tlibcurl4-openssl-dev \t\tlibdb-dev \t\tlibevent-dev \t\tlibffi-dev \t\tlibgdbm-dev \t\tlibglib2.0-dev \t\tlibgmp-dev \t\tlibjpeg-dev \t\tlibkrb5-dev \t\tliblzma-dev \t\tlibmagickcore-dev \t\tlibmagickwand-dev \t\tlibmaxminddb-dev \t\tlibncurses5-dev \t\tlibncursesw5-dev \t\tlibpng-dev \t\tlibpq-dev \t\tlibreadline-dev \t\tlibsqlite3-dev \t\tlibssl-dev \t\tlibtool \t\tlibwebp-dev \t\tlibxml2-dev \t\tlibxslt-dev \t\tlibyaml-dev \t\tmake \t\tpatch \t\tunzip \t\txz-utils \t\tzlib1g-dev \t\t\t\t$( \t\t\tif apt-cache show ‘default-libmysqlclient-dev’ 2\>\_dev\_null | grep -q ‘^Version:’; then \t\t\t\techo ‘default-libmysqlclient-dev’; \t\t\telse \t\t\t\techo ‘libmysqlclient-dev’; \t\t\tfi \t\t) \t; \trm -rf _var\_lib\_apt\_lists__"  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PATH=\_usr\_local\_bin:\_usr\_local\_sbin:\_usr\_local\_bin:\_usr\_sbin:\_usr\_bin:\_sbin:\_bin”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV LANG=C.UTF-8”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: "RUN \_bin\_sh -c set -eux; \tapt-get update; \tapt-get install -y --no-install-recommends \t\tlibbluetooth-dev \t\ttk-dev \t\tuuid-dev \t; \trm -rf var\_lib\_apt\_lists_ # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV GPG\_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PYTHON\_VERSION=3.10.13”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “RUN _bin\_sh -c set -eux; \t\twget -O python.tar.xz "afadfsdfsdfwww.python.org\_ftp\_python_${PYTHON\_VERSION%%[a-z]_}Python-$PYTHON\_VERSION.tar.xz"; \twget -O python.tar.xz.asc "afadfsdfsdfwww.python.org\_ftp\_python${PYTHON\_VERSION%%[a-z]_}\_Python-$PYTHON\_VERSION.tar.xz.asc"; \tGNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \tgpg --batch --keyserver hkps:\_keys.openpgp.org --recv-keys "$GPG\_KEY"; \tgpg --batch --verify python.tar.xz.asc python.tar.xz; \tgpgconf --kill all; \trm -rf "$GNUPGHOME" python.tar.xz.asc; \tmkdir -p \_usr\_src\_python; \ttar --extract --directory \_usr\_src\_python --strip-components=1 --file python.tar.xz; \trm python.tar.xz; \t\tcd \_usr\_src\_python; \tgnuArch="$(dpkg-architecture --query DEB\_BUILD\_GNU\_TYPE)"; \t._configure \t\t–build="$gnuArch" \t\t–enable-loadable-sqlite-extensions \t\t–enable-optimizations \t\t–enable-option-checking=fatal \t\t–enable-shared \t\t–with-lto \t\t–with-system-expat \t\t–without-ensurepip \t; \tnproc="$(nproc)"; \tEXTRA\_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \tLDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \tmake -j "$nproc" \t\t"EXTRA\_CFLAGS=${EXTRA\_CFLAGS:-}" \t\t"LDFLAGS=${LDFLAGS:-}" \t\t"PROFILE\_TASK=${PROFILE\_TASK:-}" \t; \trm python; \tmake -j "$nproc" \t\t"EXTRA\_CFLAGS=${EXTRA\_CFLAGS:-}" \t\t"LDFLAGS=${LDFLAGS:–Wl},-rpath='\$\$ORIGIN_…\_lib’" \t\t"PROFILE\_TASK=${PROFILE\_TASK:-}" \t\tpython \t; \tmake install; \t\tbin="$(readlink -ve \_usr\_local\_bin\_python3)"; \tdir="$(dirname "$bin")"; \tmkdir -p "_usr\_share\_gdb\_auto-load_$dir"; \tcp -vL Tools\_gdb\_libpython.py "_usr\_share\_gdb\_auto-load_$bin-gdb.py"; \t\tcd \_; \trm -rf \_usr\_src\_python; \t\tfind \_usr\_local -depth \t\t\( \t\t\t\( -type d -a \( -name test -o -name tests -o -name idle\_test \) \) \t\t\t-o \( -type f -a \( -name ‘_.pyc’ -o -name '_.pyo’ -o -name ‘libpython\*.a’ \) \) \t\t\) -exec rm -rf ‘{}’ + \t; \t\tldconfig; \t\tpython3 --version # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “RUN \_bin\_sh -c set -eux; \tfor src in idle3 pydoc3 python3 python3-config; do \t\tdst="$(echo "$src" | tr -d 3)"; \t\t[-s "_usr\_local\_bin_$src"]; \t\t[! -e "_usr\_local\_bin_$dst"]; \t\tln -svT "$src" "_usr\_local\_bin_$dst"; \tdone # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PYTHON\_PIP\_VERSION=23.0.1”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PYTHON\_SETUPTOOLS\_VERSION=65.5.1”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PYTHON\_GET\_PIP\_URL=afadfsdfsdfgithub.com\_pypa\_get-pip\_raw\_9af82b715db434abb94a0a6f3569f43e72157346\_public\_get-pip.py”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “ENV PYTHON\_GET\_PIP\_SHA256=45a2bb8bf2bb5eff16fdd00faef6f29731831c7c59bd9fc2bf1f3bed511ff1fe”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “RUN \_bin\_sh -c set -eux; \t\twget -O get-pip.py "$PYTHON\_GET\_PIP\_URL"; \techo "$PYTHON\_GET\_PIP\_SHA256 \*get-pip.py" | sha256sum -c -; \t\texport PYTHONDONTWRITEBYTECODE=1; \t\tpython get-pip.py \t\t–disable-pip-version-check \t\t–no-cache-dir \t\t–no-compile \t\t"pip==$PYTHON\_PIP\_VERSION" \t\t"setuptools==$PYTHON\_SETUPTOOLS\_VERSION" \t; \trm -f get-pip.py; \t\tpip --version # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-08-24T15:49:13Z”,  
“created\_by”: “CMD ["python3"]”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-10-11T11:00:00Z”,  
“created\_by”: “ARG AIRFLOW\_VERSION=2.5.3”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-10-11T11:00:00Z”,  
“created\_by”: “ARG PYTHON\_VERSION=3.10”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
},  
{  
“created”: “2023-10-11T11:00:00Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c echo ${AIRFLOW\_VERSION} ${PYTHON\_VERSION} # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:00:00Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c echo "$(echo $PYTHON\_VERSION | cut -d ‘.’ -f 1,2)" \> version.txt # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:18Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c VERSION\_MAJOR\_MINOR=$(cat version.txt) && pip install "apache-airflow[postgres,google]==${AIRFLOW\_VERSION}" --constraint "afadfsdfsdfraw.githubusercontent.com\_apache\_airflow\_constraints-${AIRFLOW\_VERSION}\_constraints-$VERSION\_MAJOR\_MINOR.txt" # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:21Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c pip install plyvel # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:21Z”,  
“created\_by”: “WORKDIR \_app”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:25Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c pip install pyroscope-io # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:25Z”,  
“created\_by”: “COPY .\_requirements.txt \_app\_requirements.txt # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:01:32Z”,  
“created\_by”: “RUN |2 AIRFLOW\_VERSION=2.5.3 PYTHON\_VERSION=3.10 \_bin\_sh -c pip install -r \_app\_requirements.txt # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:26:23Z”,  
“created\_by”: “COPY . \_app # buildkit”,  
“comment”: “buildkit.dockerfile.v0”  
},  
{  
“created”: “2023-10-11T11:26:23Z”,  
“created\_by”: “EXPOSE map[8000\_tcp:{}]”,  
“comment”: “buildkit.dockerfile.v0”,  
“empty\_layer”: true  
}  
],  
“os”: “linux”,  
“rootfs”: {  
“type”: “layers”,  
“diff\_ids”: [  
“sha256:7c85cfa30cb11b7606c0ee84c713a8f6c9faad7cb7ba92f1f33ba36d4731cc82”,  
“sha256:f6589095d5b5a4933db1a75edc905d20570c9f6e5dbebd9a7c39a8eef81bb3fd”,  
“sha256:a981dddd4c650efa96d82013fba1d1189cf4648cd1e766b34120b32af9ce8a06”,  
“sha256:01d6cdeac53917b874d5adac862ab90dcf22489b7914611a1bde7c84db0a99ae”,  
“sha256:c26432533a6af2f6f59d50aba5f76f2b61c2e0088c7e01b5d2a8708b6cb9ef08”,  
“sha256:950807b8113029e596ecd31900481c81d112069c2c644b9376b52d4f38080c9b”,  
“sha256:8e61b2657a8166cc9e7166f9af2165295c60fec29501f3b19c7a502ca912bf3a”,  
“sha256:9f64fe0537e89e159915c38bd700531a9bb6f21a6442b5a22040c4af6bf9f26b”,  
“sha256:504957b5bc380781991e584c4dec22a4851b340da66efbcb48f1821e5dd5b7bb”,  
“sha256:2f5d5ec1305274b3d5bc105edd9dfc87c49038e4f1956f3c89f8755c6008830b”,  
“sha256:d1f91d6c5c8c3c3dd737516e440462bd54de1f79cea4975ad918a988e4ea912f”,  
“sha256:2d661f5b9b0947e36d4cce9f4af907d76e8d21ca7b23ec13f5a72e29c310d535”,  
“sha256:eb8eeef061d2bf930b1cf7bd1db6d1211be664905979524e5604a619423d8d5f”,  
“sha256:dcfaefd67cfb108707cc35ba2c4a072cd70c69c6df7b8c31315529d5f7d03d42”,  
“sha256:661f27320a54eae390a7f00515b4fe43447d3eda0bd4672bb633bdb5bb180fea”,  
“sha256:7ed390f141a295fc8c91e0d4dd1aba2974d9ff55d8bc92f6e53ecfae3923e910”,  
“sha256:32c61845a69a3e01d4a8e5f1128513572b676168215a6f2755e791a28ed884a8”  
]  
},  
“config”: {  
“Cmd”: [  
“python3”  
],  
“Env”: [  
“PATH=\_usr\_local\_bin:\_usr\_local\_sbin:\_usr\_local\_bin:\_usr\_sbin:\_usr\_bin:\_sbin:_bin",  
“LANG=C.UTF-8”,  
“GPG\_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D”,  
“PYTHON\_VERSION=3.10.13”,  
“PYTHON\_PIP\_VERSION=23.0.1”,  
“PYTHON\_SETUPTOOLS\_VERSION=65.5.1”,  
“PYTHON\_GET\_PIP\_URL=afadfsdfsdfgithub.com\_pypa\_get-pip\_raw\_9af82b715db434abb94a0a6f3569f43e72157346\_public\_get-pip.py”,  
“PYTHON\_GET\_PIP\_SHA256=45a2bb8bf2bb5eff16fdd00faef6f29731831c7c59bd9fc2bf1f3bed511ff1fe”  
],  
“Labels”: {  
“com.docker.compose.project”: “dagflow”,  
“com.docker.compose.service”: “app”,  
“com.docker.compose.version”: “2.20.2”  
},  
“WorkingDir”: “app",  
“ArgsEscaped”: true  
}  
}  
},  
“Results”: [  
{  
“Target”: “dagflow-app:latest (debian 12.1)”,  
“Class”: “os-pkgs”,  
“Type”: “debian”,  
“Vulnerabilities”: [  
{  
“VulnerabilityID”: “CVE-2011-3374”,  
“PkgID”: “apt@2.6.1”,  
“PkgName”: “apt”,  
“InstalledVersion”: “2.6.1”,  
“Status”: “affected”,  
“Layer”: {  
“DiffID”: “sha256:7c85cfa30cb11b7606c0ee84c713a8f6c9faad7cb7ba92f1f33ba36d4731cc82”  
},  
“SeveritySource”: “debian”,  
“PrimaryURL”: “afadfsdfsdfavd.aquasec.com\_nvd\_cve-2011-3374”,  
“DataSource”: {  
“ID”: “debian”,  
“Name”: “Debian Security Tracker”,  
“URL”: “afadfsdfsdfsalsa.debian.org\_security-tracker-team\_security-tracker”  
},  
“Title”: “It was found that apt-key in apt, all versions, do not correctly valid …”,  
“Description”: “It was found that apt-key in apt, all versions, do not correctly validate gpg keys with the master keyring, leading to a potential man-in-the-middle attack.”,  
“Severity”: “LOW”,  
“CweIDs”: [  
“CWE-347”  
],  
“CVSS”: {  
“nvd”: {  
“V2Vector”: “AV:N\_AC:M\_Au:N\_C:N\_I:P\_A:N”,  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:H\_PR:N\_UI:N\_S:U\_C:N\_I:L\_A:N”,  
“V2Score”: 4.3,  
“V3Score”: 3.7  
}  
},  
“References”: [  
“afadfsdfsdfaccess.redhat.com\_security\_cve\_cve-2011-3374”,  
“afadfsdfsdfbugs.debian.org\_cgi-bin\_bugreport.cgi?bug=642480”,  
"[afadfsdfsdfpeople.canonical.com](http://afadfsdfsdfpeople.canonical.com)~ubuntu-security\_cve\_2011\_CVE-2011-3374.html”,  
“afadfsdfsdfseclists.org\_fulldisclosure\_2011\_Sep\_221”,  
“afadfsdfsdfsecurity-tracker.debian.org\_tracker\_CVE-2011-3374”,  
“afadfsdfsdfsnyk.io\_vuln\_SNYK-LINUX-APT-116518”,  
“afadfsdfsdfubuntu.com\_security\_CVE-2011-3374”  
],  
“PublishedDate”: “2019-11-26T00:15:00Z”,  
“LastModifiedDate”: “2021-02-09T16:08:00Z”  
},  
{  
“VulnerabilityID”: “TEMP-0841856-B18BAF”,  
“PkgID”: “bash@5.2.15-2+b2”,  
“PkgName”: “bash”,  
“InstalledVersion”: “5.2.15-2+b2”,  
“Status”: “affected”,  
“Layer”: {  
“DiffID”: “sha256:7c85cfa30cb11b7606c0ee84c713a8f6c9faad7cb7ba92f1f33ba36d4731cc82”  
},  
“SeveritySource”: “debian”,  
“PrimaryURL”: “afadfsdfsdfsecurity-tracker.debian.org\_tracker\_TEMP-0841856-B18BAF”,  
“DataSource”: {  
“ID”: “debian”,  
“Name”: “Debian Security Tracker”,  
“URL”: “afadfsdfsdfsalsa.debian.org\_security-tracker-team\_security-tracker”  
},  
“Title”: “[Privilege escalation possible to other user than root]”,  
“Severity”: “LOW”  
}  
]  
},  
{  
“Target”: “Python”,  
“Class”: “lang-pkgs”,  
“Type”: “python-pkg”,  
“Vulnerabilities”: [  
{  
“VulnerabilityID”: “CVE-2023-30861”,  
“PkgName”: “Flask”,  
“PkgPath”: “usr\_local\_lib\_python3.10\_site-packages\_Flask-2.2.3.dist-info\_METADATA”,  
“InstalledVersion”: “2.2.3”,  
“FixedVersion”: “2.3.2, 2.2.5”,  
“Status”: “fixed”,  
“Layer”: {  
“DiffID”: “sha256:d1f91d6c5c8c3c3dd737516e440462bd54de1f79cea4975ad918a988e4ea912f”  
},  
“SeveritySource”: “ghsa”,  
“PrimaryURL”: “afadfsdfsdfavd.aquasec.com\_nvd\_cve-2023-30861”,  
“DataSource”: {  
“ID”: “ghsa”,  
“Name”: “GitHub Security Advisory pip”,  
“URL”: “afadfsdfsdfgithub.com\_advisories?query=type%3Areviewed+ecosystem%3Apip”  
},  
“Title”: “flask: Possible disclosure of permanent session cookie due to missing Vary: Cookie header”,  
“Description”: “Flask is a lightweight WSGI web application framework. When all of the following conditions are met, a response containing data intended for one client may be cached and subsequently sent by the proxy to other clients. If the proxy also caches `Set-Cookie` headers, it may send one client’s `session` cookie to other clients. The severity depends on the application’s use of the session and the proxy’s behavior regarding cookies. The risk depends on all these conditions being met.\n\n1. The application must be hosted behind a caching proxy that does not strip cookies or ignore responses with cookies.\n2. The application sets `session.permanent = True`\n3. The application does not access or modify the session at any point during a request.\n4. `SESSION_REFRESH_EACH_REQUEST` enabled (the default).\n5. The application does not set a `Cache-Control` header to indicate that a page is private or should not be cached.\n\nThis happens because vulnerable versions of Flask only set the `Vary: Cookie` header when the session is accessed or modified, not when it is refreshed (re-sent to update the expiration) without being accessed or modified. This issue has been fixed in versions 2.3.2 and 2.2.5.”,  
“Severity”: “HIGH”,  
“CweIDs”: [  
“CWE-539”  
],  
“CVSS”: {  
“ghsa”: {  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:L\_PR:N\_UI:N\_S:U\_C:H\_I:N\_A:N”,  
“V3Score”: 7.5  
},  
“nvd”: {  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:L\_PR:N\_UI:N\_S:U\_C:H\_I:N\_A:N”,  
“V3Score”: 7.5  
},  
“redhat”: {  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:L\_PR:N\_UI:N\_S:U\_C:H\_I:N\_A:N”,  
“V3Score”: 7.5  
}  
},  
“References”: [  
“afadfsdfsdfaccess.redhat.com\_security\_cve\_CVE-2023-30861”,  
“afadfsdfsdfcve.mitre.org\_cgi-bin\_cvename.cgi?name=CVE-2023-30861”,  
“afadfsdfsdfgithub.com\_pallets\_flask”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_commit\_70f906c51ce49c485f1d355703e9cc3386b1cc2b”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_commit\_8646edca6f47e2cd57464081b3911218d4734f8d (2.2.5)”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_commit\_8705dd39c4fa563ea0fe0bf84c85da8fcc98b88d (2.3.2)”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_commit\_afd63b16170b7c047f5758eb910c416511e9c965”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_releases\_tag\_2.2.5”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_releases\_tag\_2.3.2”,  
“afadfsdfsdfgithub.com\_pallets\_flask\_security\_advisories\_GHSA-m2qf-hxjv-5gpq”,  
“afadfsdfsdfgithub.com\_pypa\_advisory-database\_tree\_main\_vulns\_flask\_PYSEC-2023-62.yaml”,  
“afadfsdfsdflinux.oracle.com\_cve\_CVE-2023-30861.html”,  
“afadfsdfsdflinux.oracle.com\_errata\_ELSA-2023-12710.html”,  
“afadfsdfsdflists.debian.org\_debian-lts-announce\_2023\_08\_msg00024.html”,  
“afadfsdfsdfnvd.nist.gov\_vuln\_detail\_CVE-2023-30861”,  
"afadfsdfsdfsecurity.netapp.com\_advisory\_ntap-20230818-0006_”,  
“afadfsdfsdfubuntu.com\_security\_notices\_USN-6111-1”,  
“afadfsdfsdfwww.cve.org\_CVERecord?id=CVE-2023-30861”,  
“afadfsdfsdfwww.debian.org\_security\_2023\_dsa-5442”  
],  
“PublishedDate”: “2023-05-02T18:15:00Z”,  
“LastModifiedDate”: “2023-08-20T21:15:00Z”  
},  
{  
“VulnerabilityID”: “CVE-2023-29005”,  
“PkgName”: “Flask-AppBuilder”,  
“PkgPath”: “usr\_local\_lib\_python3.10\_site-packages\_Flask\_AppBuilder-4.1.4.dist-info\_METADATA”,  
“InstalledVersion”: “4.1.4”,  
“FixedVersion”: “4.3.0”,  
“Status”: “fixed”,  
“Layer”: {  
“DiffID”: “sha256:d1f91d6c5c8c3c3dd737516e440462bd54de1f79cea4975ad918a988e4ea912f”  
},  
“SeveritySource”: “ghsa”,  
“PrimaryURL”: “afadfsdfsdfavd.aquasec.com\_nvd\_cve-2023-29005”,  
“DataSource”: {  
“ID”: “ghsa”,  
“Name”: “GitHub Security Advisory pip”,  
“URL”: “afadfsdfsdfgithub.com\_advisories?query=type%3Areviewed+ecosystem%3Apip”  
},  
“Title”: “Flask-AppBuilder Has No Rate Limiting on Login AUTH DB”,  
“Description”: “Flask-AppBuilder versions before 4.3.0 lack rate limiting which can allow an attacker to brute-force user credentials. Version 4.3.0 includes the ability to enable rate limiting using `AUTH_RATE_LIMITED = True`, `RATELIMIT_ENABLED = True`, and setting an `AUTH_RATE_LIMIT`.”,  
“Severity”: “HIGH”,  
“CweIDs”: [  
“CWE-307”  
],  
“CVSS”: {  
“ghsa”: {  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:L\_PR:N\_UI:N\_S:U\_C:H\_I:N\_A:N”,  
“V3Score”: 7.5  
},  
“nvd”: {  
“V3Vector”: “CVSS:3.1\_AV:N\_AC:L\_PR:N\_UI:N\_S:U\_C:H\_I:N\_A:N”,  
“V3Score”: 7.5  
}  
},  
“References”: [  
“afadfsdfsdfflask-limiter.readthedocs.io\_en\_stable\_configuration.html”,  
“afadfsdfsdfgithub.com\_dpgaspar\_Flask-AppBuilder”,  
“afadfsdfsdfgithub.com\_dpgaspar\_Flask-AppBuilder\_pull\_1976”,  
“afadfsdfsdfgithub.com\_dpgaspar\_Flask-AppBuilder\_releases\_tag\_v4.3.0”,  
“afadfsdfsdfgithub.com\_dpgaspar\_Flask-AppBuilder\_security\_advisories\_GHSA-9hcr-9hcv-x6pv”,  
“afadfsdfsdfnvd.nist.gov\_vuln\_detail\_CVE-2023-29005”  
],  
“PublishedDate”: “2023-04-10T21:15:00Z”,  
“LastModifiedDate”: “2023-04-18T17:02:00Z”  
}  
]  
}  
]  
}

I have to insert this to dgraph using pydgraph. How to do that?

Any help will be much appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [November 27, 2023, 4:16pm UTC](https://discuss.dgraph.io/t/complex-nested-json-data-to-dgraph/19084/2 "2023-11-27T16:16:32Z")

</div>

My friend, please use code block formatting! (three backticks before and after the code)

To answer your question, there is not a one size fits all for storing JSON data in Dgraph. You title, calls your data “complex nested”, but the data schema is not really all that complex in terms of JSON. You should be able to write this data directly and query it back out with DQL. What you will need to watch out for and be aware of is the following:

1. Handling of “Arrays” in Dgraph. Dgraph treats arrays like sets, so duplicates and order are not preserved.
2. Lack of support for multi-dimensional arrays. I don’t see this in your dataset example, but just be aware of it.
3. Predicate naming/typing. I don’t see this problem in your dataset either, but for instance, if in one place you used the key (aka predicate) “foo” to map to a string, and then later “foo” maps to an array or object, or even DateTime then you will have problems. The workaround to this is to prepend the type to the predicate like Dgraph does under the hood with GraphQL schema.
4. Deep updating without having uids. This might not be that evident if just saving JSON data and not needing to modify it, but when you do need to modify it, modifying a nested portion of it can be tricky to do and usually you will find yourself appending to existing adding new nested nodes instead of modifying the existing nested nodes.
5. Typing nested data. If you want your data to work with Dgraph types, then you will need to manually add the `dgraph.type` predicates to every object in your JSON data.

A workaround to all of this is to store the JSON as a string, but that might really take away the value of using Dgraph for your use case.
