Skip to content

Commit

Permalink
Implement ParsesReferences from latest bsb-core
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed May 21, 2024
1 parent 58295ad commit b19f39d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bsb_json/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import json

import numpy as np
from bsb.config.parsers import ReferenceParser
from bsb.config.parsers import ConfigurationParser, ParsesReferences


def _json_iter(obj): # pragma: nocover
Expand All @@ -25,7 +25,7 @@ def _to_json(value):
raise TypeError(f"Can't encode '{value}' ({type(value)})")


class JsonParser(ReferenceParser):
class JsonParser(ParsesReferences, ConfigurationParser):
"""
Parser plugin class to parse JSON configuration files.
"""
Expand All @@ -34,11 +34,10 @@ class JsonParser(ReferenceParser):
data_extensions = ("json",)
data_syntax = "json"

def from_str(self, filename):
return json.loads(filename)

def load_content(self, stream):
return json.load(stream)
def parse(self, content, path=None):
if isinstance(content, str):
content = json.loads(content)
return content, {"meta": path}

def generate(self, tree, pretty=False):
if pretty:
Expand Down

0 comments on commit b19f39d

Please sign in to comment.