https://github.com/marcastr0/json-to-prolog
Simple Javascript library for converting JSON objects to Prolog facts.
https://github.com/marcastr0/json-to-prolog
json nodejs prolog
Last synced: about 2 months ago
JSON representation
Simple Javascript library for converting JSON objects to Prolog facts.
- Host: GitHub
- URL: https://github.com/marcastr0/json-to-prolog
- Owner: MarcAstr0
- License: mit
- Created: 2018-04-09T14:08:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T13:17:30.000Z (over 7 years ago)
- Last Synced: 2025-01-27T07:44:25.695Z (over 1 year ago)
- Topics: json, nodejs, prolog
- Language: JavaScript
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-to-prolog
[](https://lbesson.mit-license.org/)
## Overview
Simple Javascript library for converting JSON objects to Prolog facts. Useful for converting, for
example, results from a database query to Prolog facts.
For example, the following object:
```json
{
"parent": [
{ "parent": "mike", "child": "greg" },
{ "parent": "mike", "child": "marcia" },
{ "parent": "mike", "child": "peter" },
{ "parent": "mike", "child": "jan" },
{ "parent": "mike", "child": "bobby" },
{ "parent": "mike", "child": "cindy" },
{ "parent": "carol", "child": "greg" },
{ "parent": "carol", "child": "marcia" },
{ "parent": "carol", "child": "peter" },
{ "parent": "carol", "child": "jan" },
{ "parent": "carol", "child": "bobby" },
{ "parent": "carol", "child": "cindy" }
]
}
```
Will convert to:
```prolog
% parent(Parent, Child).
parent(mike, greg).
parent(mike, marcia).
parent(mike, peter).
parent(mike, jan).
parent(mike, bobby).
parent(mike, cindy).
parent(carol, greg).
parent(carol, marcia).
parent(carol, peter).
parent(carol, jan).
parent(carol, bobby).
parent(carol, cindy).
```
The JSON object must follow the following format:
```json
{
"predicate1": [
{ "argument1": "someValue", ..., "argumentN": "anotherValue"},
...,
{ "argument1": "andAnotherValue", ..., "argumentN": "etc."}
],
...,
"predicateN": [
...
]
}
```
Each property of the main object describes a predicate, and each predicate has an array (list) of
facts represented as objects, with the predicate's arguments as properties.
## Installation
## Usage
## To Do
* Complete the README.
* Add a method for converting _from_ Prolog to JSON.