Giter Site home page Giter Site logo

tlv's Introduction

C++ Assignment: JSON Packer

The task is to read data in JSON format and using dictionary encoding write a compressed stream to disk.

The code should compile with gcc on debian linux.

You may use the following: • boost • some JSON parser library • cmake or simple make

The input will contain records in JSON format. Each record is separated by a new line (LF). The input will only contain simple types, complex and nested data structures will not be present (i.e. map and array).

Input example: { “key1”:“value”, “key2”:42, “key3”:TRUE} {“sadsf”:”dsewtew”, “dsre”:3221, “sdfds”:”dsfewew”}

Basically a record is a list of KVPs (key-value pairs). Once the input is read, the program should encode the input so that the keys are put into a dictionary. The dictionary maps the keys (strings) to an integer. The key strings are then replaced with a number.

The dictionary would be as follows for the first record: “key1”:1, “key2”:2, “key3”:3

This record is then represented as: { 1:“value”, 2:42, 3:TRUE}

Types supported by JSON must be handled and preserved (i.e. integer, string, boolean). The output should be dumped to a file in a binary form using TLV encoding instead of the above text-based representation. This binary TLV encoding is more compact, e.g. a boolean value can be encoded in two bytes (or even less).

At the end of the process the dictionary must be also written to a file using the same encoding method for the string-integer pairs.

The input file can be arbitrary large, make sure to use streaming instead of reading everything into memory. You can assume that the key space (number of distinct key strings) is small and regular inmemory structures (i.e. hashtable) can be used for the dictionary.

While completing this task please try to show your skills (including C++11). Clear, readable and documented code is preferred. Avoid writing obfuscated code, speed should be a secondary objective. Feel free to add unit tests.

Note: This simple assignment shows a very basic algorithm which might be useful to you in the project later but in no way can it be used by us as is.

Prerequisites

  • Python3
  • CMake
  • Conan
  • gcc

How To Use

$ sudo apt update
$ sudo apt install -y python3 python3-pip build-essential
$ pip3 install --user conan ninja cmake
$ source ~/.profile
$ conan install . -b missing -s build_type=Debug
$ conan install . -b missing -s build_type=Release
$ cmake --workflow --preset gcc-debug
$ cmake --workflow --preset gcc-release

tlv's People

Contributors

raygerlabs avatar

Watchers

 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.