ParseNotEval.jl

Expands the usage of Base.parse to work with more Base structures.
Author ChifiSource
Popularity
8 Stars
Updated Last
6 Months Ago
Started In
April 2022

version deps pkgeval

ParseNotEval Is a core odd data package that acts as both an implicit and explicit type parser. The main usage for such a thing is in file/string reading, by being able to quickly parse strings into their appropriate types. This is helpful if you want to make secure and fast data readers. This module is moreso ecosystem geared.

adding and using

Until the team is ready to release a stable version (very soon, likely today,) you will need to add the package via URL:

using Pkg
Pkg.add(url = "https://github.com/ChifiSource/ParseNotEval.jl.git")

The only thing that this module exports is the parse method and Dates.DateTime + Dates.Date. The extensions provided to parse() allow for one to pass tons of different types and structures through in order to create them. For example, we could read a Dict in from a string:

dct_str = "A => [5, 10, 15], B => [5, 10, 15]"
parse(Dict, dct_string)
Dict(:A => [5, 10, 15], :B => [5, 10, 15])

# This also works with JSON.
dct_str = "{A : [5, 10, 15], B : [5, 10, 15]}"
parse(Dict, dct_string)
Dict(:A => [5, 10, 15], :B => [5, 10, 15])

There are a lot more structures involved as well, the best choice is to use ?(parse) to get the docs all of the methods for parse, or view the JuliaHub documentation. One notable other example is that of parse(Any, ::String).

typeof(parse(Any, 5.0))
Float64
typeof(parse(Any, 5))
Int64

Required Packages

No packages found.

Used By Packages