Skip to content

POC: JSON-LD parsing without rdflib - #696

Closed
armintaenzertng wants to merge 1 commit into
spdx:mainfrom
armintaenzertng:json_parsing
Closed

armintaenzertng wants to merge 1 commit into
spdx:mainfrom
armintaenzertng:json_parsing

Conversation

@armintaenzertng

@armintaenzertng armintaenzertng commented Jun 14, 2023 •

Copy link
Copy Markdown
Collaborator

Important feature is the module with the string to class mappings, which we will probably need for every serialization format.

Also adds a full workflow test, consisting of conversion->writing->parsing->writing, then comparing the two written outputs.

@armintaenzertng
armintaenzertng marked this pull request as ready for review June 15, 2023 11:41
@armintaenzertng
armintaenzertng force-pushed the json_parsing branch 2 times, most recently from cafb7c7 to 4571d6e Compare June 15, 2023 11:44
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
import json
from typing import Union

from beartype.typing import Dict, List

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the wrong import, should just be typing?


context = input_as_dict["@context"]
custom_context = {}
if isinstance(context, list):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if @context is just a single dict? Shouldn't custom_context then be seeded with that dict?



def parse_element_object(element_object: Union[Dict, str], custom_context: Dict):
if isinstance(element_object, str):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, JSON also supports numbers, booleans and null directly. Don't we need to handle them in similar fashion?

else:
element_properties[camel_case_to_snake_case(key)] = value

if element_type not in CLASS_DICT:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved before the for loop?

@armintaenzertng
armintaenzertng marked this pull request as draft July 28, 2023 09:57
@armintaenzertng armintaenzertng changed the title add json-parsing prototype POC: add JSON-LD parsing without rdflib Jul 28, 2023
@armintaenzertng armintaenzertng changed the title POC: add JSON-LD parsing without rdflib POC: JSON-LD parsing without rdflib Jul 28, 2023
@maxhbr

maxhbr commented Mar 22, 2024

Copy link
Copy Markdown
Member

This is stale, and https://github.com/JPEWdev/shacl2code is expected to replace it

@maxhbr maxhbr closed this Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants