From d8749d1985a45450b0b007af334ff6d554c8ac38 Mon Sep 17 00:00:00 2001 From: Devon Sawatsky Date: Wed, 5 Aug 2026 02:46:23 +0000 Subject: [PATCH] numerical --- data/user.json | 2 +- src/lib.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/data/user.json b/data/user.json index a51c2a0..7b186fe 100755 --- a/data/user.json +++ b/data/user.json @@ -1 +1 @@ -{"userId":1234,"email":"user@example.com","pendingEmail":null,"birthdate":"2000-01-01T00:00:00.000Z","freshdeskContactId":null,"emailVerified":true,"emailVerifyCanceled":false,"collapseAdultContent":false,"activatedByInviteId":"a0d6f2e0-c499-4ce2-a10c-0ed882f04181","stripeCustomerId":null,"settings":{"collapseLongThreads":true,"gifsStartPaused":false,"pauseProfileGifs":false,"disableEmbeds":false,"externalLinksInNewTab":true,"enableNotificationCount":true,"suggestedFollowsDismissed":true,"enableMobileQuickShare":true,"beatsTimestamps":false,"autoExpandAllCws":false,"disableModalPostComposer":false,"homeView":"dashboard","defaultShow18PlusPostsInSearches":true,"defaultPostBoxTheme":"dark","previewFeatures_lexicalPostEditor":true,"chaosDay2023_showNumbers":true},"silencedCWs":["cw1","\b\\\t\f\/cw2","#cw 3"],"autoexpandCWs":["cw4","cw5\r\n","#cw6"],"collapsedTags":["tag1","\"tag2","#ta g3"],"notificationFilters":{"includeLikes":true,"includeShares":true,"includeFollows":true,"includeReplies":true,"includeComments":true},"lastActivityTime":"2024-10-01T12:0:0.123Z"} \ No newline at end of file +{"userId":1234,"email":"user@example.com","pendingEmail":null,"birthdate":"2000-01-01T00:00:00.000Z","freshdeskContactId":null,"emailVerified":true,"emailVerifyCanceled":false,"collapseAdultContent":false,"activatedByInviteId":"a0d6f2e0-c499-4ce2-a10c-0ed882f04181","stripeCustomerId":null,"settings":{"collapseLongThreads":true,"gifsStartPaused":false,"pauseProfileGifs":false,"disableEmbeds":false,"externalLinksInNewTab":true,"enableNotificationCount":true,"suggestedFollowsDismissed":true,"enableMobileQuickShare":true,"beatsTimestamps":false,"autoExpandAllCws":false,"disableModalPostComposer":false,"homeView":"dashboard","defaultShow18PlusPostsInSearches":true,"defaultPostBoxTheme":"dark","previewFeatures_lexicalPostEditor":true,"chaosDay2023_showNumbers":true},"silencedCWs":["cw1","\\\t\/cw2","#cw 3"],"autoexpandCWs":["cw4","cw5\r\n","#cw6"],"collapsedTags":["tag1","\"tag2","#ta g3"],"notificationFilters":{"includeLikes":true,"includeShares":true,"includeFollows":true,"includeReplies":true,"includeComments":true},"lastActivityTime":"2024-10-01T12:0:0.123Z"} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 8a0331d..534ae52 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,10 @@ use nom::{ IResult, Parser, branch::alt, bytes::complete::{tag, take_till1}, + character::complete::one_of, combinator::value, multi::separated_list0, + number::complete::double, sequence::delimited, }; use std::collections::HashMap; @@ -84,12 +86,22 @@ fn parse_pair(input: &str) -> IResult<&str, (String, JsonValue)> { .map(|(k, _, v)| (k, v)) .parse(input) } +fn parse_integer(input: &str) -> IResult<&str, JsonValue> { + ( + nom::character::complete::i64, + nom::combinator::not(one_of("eE.")), + ) + .map(|(i, _)| JsonValue::Integer(i)) + .parse(input) +} pub fn deserialize_json(json: &str) -> IResult<&str, JsonValue> { // map_res(); alt(( parse_null, parse_bool, + parse_integer, + double.map(JsonValue::Float), parse_string.map(JsonValue::String), parse_array, parse_object, -- 2.51.2