Code Monkey home page Code Monkey logo

json-to-prolog's Introduction

json-to-prolog

MIT license

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:

{
  "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:

% 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:

{
  "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.

json-to-prolog's People

Contributors

marcastr0 avatar

Stargazers

Devi Acharya avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.