JSON.IsValid
------------

Checks if JSON text is valid.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [6.3](newinversion63.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.IsValid"; JSON ) 

**MBS**( **"JSON.IsValid";** /\* Checks if JSON text is valid. \*/  
**$JSON**) /\* The JSON text to parse.e.g. "\[1,2,3\]" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| JSON | The JSON text to parse. | "\[1,2,3\]" |

### Result

Returns 1, 0 or error.

### Description

Checks if JSON text is valid.  
This parses the JSON text and returns 1 on success or 0 on failure.  
  
This checks if the given text is a valid JSON fragment and can be e.g. added as value to a JSON object or array. So this returns 1 for proper formatted boolean, number and text pieces, too.  
### Examples

Checks validity:

 MBS ( "JSON.IsValid"; "\[1,2,3\]" )  
<small>  
Example result: 1</small>Checks with error:

 MBS ( "JSON.IsValid"; "\[1,hello,3\]" )  
<small>  
Example result: 0</small>Check number:

 MBS ("JSON.IsValid"; 123)  
<small>  
Example result: 1</small>### See also

- [IBAN.IsValid](IBANIsValid.md)

### Release notes

- **Version 14.3**
    - Reimplemented [JSON.IsValid](https://www.mbsplugins.eu/JSONIsValid.shtml) using newer [JSON](https://www.mbsplugins.eu/component_JSON.shtml) functions internally, so it catches more errors.
- **Version 12.5**
    - Fixed a problem with [JSON.IsValid](https://www.mbsplugins.eu/JSONIsValid.shtml) accepting garbage characters behind parsing.

### Blog Entries

- [MBS FileMaker Plugin, version 14.3pr5](https://www.mbsplugins.de/archive/2024-06-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.5pr4](https://www.mbsplugins.de/archive/2022-10-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.3pr4](https://www.mbsplugins.de/archive/2016-06-24/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2020, Seite 16](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function is free to use.

Created 23th June 2016 , last changed 25th June 2024

  
[JSON.InsertRecords](JSONInsertRecords.md) - [JSON.JSONPatch.ApplyPatch](JSONJSONPatchApplyPatch.md)

[HTML Version](JSONIsValid.shtml)