Need to find lines that are missing a comma at the end.
-
Try searching for
[^,]$
after setting the Search mode to Regular expression. -
@Alan-Kilborn Thank you for your response. I have tried both and neither has come up with anything worth noting… so I suppose the error is not due to the lack of a comma. Do you know of any way to perhaps search for the format of each line and accordingly isolate lines that don’t fit the usual format? I’m not sure if that request is within NP++'s capabilities.
-
Hm, well from the sample data we can maybe draw some conclusions…
You might try a Mark operation using the following regular expression:
(?-s)^".+?": ".+?",$
It should turn the background of all lines red that conform to what seems to be your format.
Note that this is fairly “loose” as I really have no idea what truly constitutes a valid line format that is accepted by whatever tool is using the file.
-
@Alan-Kilborn
I used the Mark operation and did not find any matching results (There is a nonzero chance I did it wrong)I would like to provide more information about how the data is being utilized but struggle to describe how it is as I am not very experienced in this field. For what it’s worth, the information is being accessed by Minecraft and applied to specific text labels spread out through different areas of the game. Here’s another screenshot with more data that is (hopefully) more useful. Any ideas? Thank you for your help up to this point, by the way.
-
Your file format looks rather JSON-like. If the simple checks that @Alan-Kilborn has pointed out are not finding anything, you might try installing the JSONTools plugin which (IIRC) can do a syntax check on JSON, and might take you to the line where it’s wrong. If that doesn’t find it, then it’s probably not a syntax error, and it’s instead a data-error: ie, some valid JSON string is something that the minecraft engine cannot handle, hence your problem – but if that’s the case, we won’t be able to help you, because this is not a minecraft-modding forum.
-
Offhand, I can’t see why the marking operation didn’t work for you. Of course, we’re just working from pictures, not actual sample text. Usually the first thing we do is ask for real text. This case seemed so simple, though… :-(
-
@PeterJones It is a JSON file, yes. I didn’t insert any characters or information that Minecraft is incapable of handling so I really feel as though it’s something vital that I accidentally deleted. I will install the plugin and see if it helps. Thank you for your assistance.
-
The other thing you can do, if you have the original version of the JSON file, is to use the ComparePlus plugin and compare the old to the new, and thus see all the changes that were made. That might help you narrow down where the problem is.
-
Hello, @monarchia, @alan-kilborn, @peterjones and all,
Well, @monarchia, after using the
Irfanview
sofware with a recognition characters plugin and some minor ajustments, I was able to extract this text from your first image which can be transformed into this functionaljson
block, below :{ "narrator.position.object list": "Selected row element %s out of %s", "narration.suggestion.tooltip": "Selected suggestion %d out of %d: %s (%s)", "narration.suggestion": "Selected suggestion %d out of %d: %s", "narration.button": "Button: %s", "narration.button.usage.focused": "Press Enter to activate", "narration.button.usage.hovered": "Left click to activate", "narration.cycle button.usage.focused": "Press Enter to si~tc:~ to %s", "narration.cycle~button.usage.hovered": "Left click to switc:~ to %s", "narration.checkbox": "Checkbox: %s", "narration.checkbox.usage.focused": "Press Enter to toggle", "narration.checkbox.usage.hovered": "Left click to toggle", "narration.recipe": "Reciple for %s", "narration.recipe.usage": "Left click to select", "narration.recipe.usage.miore": "Right click to show miore reclpes", "narration.selection.usage": "Press up and down buttons to nove to another entry", "narration.comqoonent~list.usage": "Press Tab to navigate to next element", "narration.slider.usage.focused": "Press left or right keyboard buttons to change value", "narration.slider.usage.hovered": "Drag slider to change value", "narration.edit~box": "Edit box: %s" }
Now, @monarchia, try the following method to get all specific lines which do not have the right format :
-
Open the Mark dialog (
Ctrl + M
) -
Untick all box options
-
SEARCH
(?x-s) ^ \h* " .+? " : \x20 " .+ ? " , $ (*SKIP) (*F) | ^ .+
-
Check the 2 options
Bookmark line
, andPurge for each search
-
Select the
Regular expression
search mode -
Move to the very beginning of your
json
file -
Click on the
Mark All
button -
Now, hit the
F2
key, repeatedly, to get the different lines which do not satisfy your format !
Remark the part
\h*
, at beginning of the regex, which could explain why the previous @alan-kilborn’s solution found nothing !
Running this regex against the
json
block above, previously copied in a new tab, should obviously mark the lines{
and}
, as well as the last data line"narration.edit~box": "Edit box: %s"
which does not end with acomma
character !Best Regards,
guy038
PS :
Alan, in order to mark all lines not ending with a
comma
char, I suppose that the regex[^,\r\n]$
is a better bet ! -
-
@Monarchia
Looks like you got this fixed, but just wanted to chime in that JsonTools can indeed find the errors in your JSON file (as PeterJones mentioned), but you can also just turn on linting and then you can parse the JSON with any number of missing commas (as well as various other syntax errors) and pretty-print it as syntactically valid JSON.If your JSON file had a truly preposterous number of such syntax errors (say on the order of hundreds of thousands), the linter would probably use a lot of memory though.