4 kyu
JSON Parser
121 of 204joebandenburg
Loading description...
JSON
Parsing
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I'm trying to post my solution and I keep getting an error from anti-chit -
You cannot do that.
What exactly can't I do, what do I need to fix? I'm tired of playing the guessing game. These rules should be clearly spelled out. I realize it probably doesn't like some of the naming in my code, but I shouldn't have to guess, the error should clearly tell me what needs to be changed.JSON.parse
andeval
I understandably don't use.I will try to improve the message, but you'd have to tell me the language you are attempting.
EDIT: your solution most probably triggers this condition of the anti-cheat:
sol.includes('Function')
.The
javascript
language. I thought maybe the problem was that I was usingJSON
in the class name, but no, by changing it it still didn't work.Yeah, well, that's the way it is. I had a variable called
convertFunctions
in my code and it was the variable that the anti-reader didn't like. Thank you @hobovsky for responding so quickly and helping me. However, I think it is either worth improving the error message. As I wrote above -You cannot do that
doesn't say anything, given that there is no mention ofFunction
being forbidden. Or could we update the description and add clearer requirements as to what is being tested in this test?The message and the description need to be fixed, yes. Just leave this issue open and someone will take care of this.
I just checked the code of tests to make you able to m9ve forward before the problem gets addressed.
Roger that. Thank you!
Prolog translation
At least in Haskell, "valid ones" section of random tests generates numbers with exponent and expects the user to parse them, which contradicts the description. Example (note
-3.458508438120589e-2
near the very end):js at least: missing a fixed test with a string beginning with a whitespace. Fortunately, it appears frequently in the random tests, but having it in the fixed tests would be more comfortable. Increasing a bit the number of random tests would be a good idea too, to be sure tha nobody can slip through the tests.
Description doesn't mention spaces at all ATM. That would be good to update as well then.
The Haskell code block should not be visible in the JS version of the description.
Fixed. I think.
Is it OK now?
Should tests ignore the order of pairs parsed in Object?
Please not. That's a nightmare to test, at least in Haskell.
Only because it uses the wrong type. https://tools.ietf.org/html/rfc8259
It should be a
Map
in the first place.Except that spec is not part of the description, we are already using simplifications here and there, and the JS tests are not unordered either ( they could have been, with
assertDeepEquals
, but they are not, withassertSimilar
). Because JS does have something of an ordering in objects, at least sometimes ( and sometimes not ).It's a bit of a wasps' nest. But I tend towards wanting to preserve existing ordering, and the source has an ordering.
( I may not have thought of all this when translating or when having visions of nightmares. )
Note that I don't get notifications for this thread. If the translation must be updated, please comment on the translation suggestion.
And neither the grammar nor the description mentions whitespace should be ignored.
Otherwise stated: the "grammar" does not differentiate clearly between terminal and non-terminal symbols.
Haskell description does not give literal value to parse for Null.
(
true
,false
and )null
is / are specified undervalue
. These are intended as literal strings. This is not specific for Haskell either; it's in the shared part of the description.Haskell test is parsing Bool wrong; description mentions literals "True" and "False", whereas test code uses "true".
True
andFalse
are mentioned as result values, not input values.true
andfalse
( andnull
) are specified undervalue
. These are intended as literal strings.This is consistent with normal JSON.
Haskell translation
Bump.
Somebody approve it, I promise it's OK and OP is gone.
( one year later ) ETA: famous last words ..
Looks good. Could you remove the mention of
JSON.parse
from the description as I don't think that applies in Haskell? Also it looks like some of the description text is inside code blocks for some reason.Those are artifacts of the rendering for that particular view - neither is actually there.
```if:javascript
is rendered as a codeblock, that's what's happening. Everywhere else, such a block is rendered as normal text ( when the language checks ).No change is necessary.
Bump ..
@johan: did you see the issues above?
No! ( This is why issues with translations should [ also ] be posted on the translation comment / suggestion. I did get a notification for this. )
I'll have a look.
@joebandenburg
, this is a great kata but it needs random tests. Marking this as an issue because a kata at this kyu ranking (approx. 3kyu) needs to have random tests.EDIT: BTW, I added some anti-cheats to prevent loopholes like the one reported by
@Freywar
.This is a good quality kata so I went ahead and added random tests. If anybody encounters any issues with the random tests, reply to this message, otherwise I may not see the alert in this Discourse section.
@docgunthrop
I've been inactive. Thanks for improving my Kata :-)This comment has been hidden.
That loophole is now fixed. Thanks for the bug report.
I think this one would be relatively easy to translate into other langauges. The only JavaScript-specific elements are tests and the disabling of standard library JSON parsers. Translations welcome! :)
A Haskell translation is now available for approval.