# How to create a wrapper package

**URL:** <https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605>\
**Category:** General Usage\
**Created:** [September 19, 2024, 1:39pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605 "2024-09-19T13:39:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [September 19, 2024, 1:39pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/1 "2024-09-19T13:39:12Z")

</div>

I’m interested in using [HJSON](https://hjson.github.io) but it’s quite annoying to run hjson every time and create a json file that I can then read with JSON3. How would I go about creating a HJSON.jl such that I can do the conversion inside julia which would already be an improvement and then probably just have a readhjson function that goes through conversion and reading it using JSON3 in one go.

Looking forward to any pointers of how to create such a wrapper package.

---

<div class="post-metadata">

**Author:** ![HanD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hand/32/213908_2.png) [@HanD](https://discourse.julialang.org/u/HanD)\
**Post date:** [September 19, 2024, 3:04pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/2 "2024-09-19T15:04:06Z")

</div>

You don’t really need a package for that. If you have the `hjson` binary on your path, then the following simple function should suffice:

```julia
using JSON

function hjson_parse(file::AbstractString; kwargs...)
    json = Pipe()
    run(pipeline(`hjson -c $file`, json); wait = false)
    return JSON.parse(json; kwargs...)
end

```

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [September 19, 2024, 4:03pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/3 "2024-09-19T16:03:48Z")

</div>

The problem is installing that binary on the servers I need to run my stuff on so I need some kind of jll stuff I would guess

---

<div class="post-metadata">

**Author:** ![HanD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hand/32/213908_2.png) [@HanD](https://discourse.julialang.org/u/HanD)\
**Post date:** [September 19, 2024, 5:00pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/4 "2024-09-19T17:00:30Z")

</div>

I don’t see why that’s a problem. The tool doesn’t require installation, it’s just an ELF binary that can be downloaded and extracted from the homepage.

```julia
curl -L https://github.com/hjson/hjson-go/releases/download/v4.4.0/hjson_v4.4.0_linux_amd64.tar.gz | tar xz ./hjson

```

In this case, you need to modify the above julia snippet to call `./hjson` instead of plain `hjson`, otherwise it won’t be able to find the binary, but that’s it. You can carry a copy of the `hjson` binary with your code, even commit it into your repository, etc.

If you really need, you can even make this part of your julia code:

```julia
using JSON

const URL = "https://github.com/hjson/hjson-go/releases/download/v4.4.0/hjson_v4.4.0_linux_amd64.tar.gz"

function hjson_parse(file::AbstractString; kwargs...)
    if !isfile("hjson")
        run(pipeline(`curl -sL $URL`, `tar xz ./hjson`))
    end
    json = Pipe()
    run(pipeline(`./hjson -c $file`, json); wait = false)
    return JSON.parse(json; kwargs...)
end

```

---

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [September 19, 2024, 5:17pm UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/5 "2024-09-19T17:17:58Z")

</div>

[GitHub - JuliaPackaging/BinaryBuilder.jl: Binary Dependency Builder for Julia](https://github.com/JuliaPackaging/BinaryBuilder.jl) supports Go so it should be relatively straight forward to make a jll of [GitHub - hjson/hjson-go: Hjson for Go](https://github.com/hjson/hjson-go).

An example of a go app on Yggdrasil is [Yggdrasil/G/goaws/build\_tarballs.jl at 5c85d729b0f178277359ace7f9091c8677fbf777 · JuliaPackaging/Yggdrasil · GitHub](https://github.com/JuliaPackaging/Yggdrasil/blob/5c85d729b0f178277359ace7f9091c8677fbf777/G/goaws/build_tarballs.jl#L17)

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [September 25, 2024, 7:56am UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605/6 "2024-09-25T07:56:48Z")

</div>

Thanks. My colleague just created: [GitHub - fmatesa/HJSON.jl](https://github.com/fmatesa/HJSON.jl)
