
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@opsystech/ang-jsoneditor
Advanced tools
[](https://travis-ci.org/mariohmol/ang-jsoneditor)
Angular Json Editor (wrapper for jsoneditor). View/Edit Json file with formatting.
Working with latest Angular 9.
To install this library with npm, run below command:
$ npm install --save jsoneditor ang-jsoneditor
Example:
<json-editor [options]="editorOptions" [data]="data" (change)="getData($event)"></json-editor>
First, Import Angular JsonEditor module in root
import { NgJsonEditorModule } from 'ang-jsoneditor'
@NgModule({
declarations: [
AppComponent
],
imports: [
....,
NgJsonEditorModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Then setup your component models as below :
import { Component, ViewChild } from '@angular/core';
import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
@Component({
selector: 'app-root',
template: '<json-editor [options]="editorOptions" [data]="data"></json-editor>',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public editorOptions: JsonEditorOptions;
public data: any;
@ViewChild(JsonEditorComponent, { static: false }) editor: JsonEditorComponent;
constructor() {
this.editorOptions = new JsonEditorOptions()
this.editorOptions.modes = ['code', 'text', 'tree', 'view']; // set all allowed modes
//this.options.mode = 'code'; //set only one mode
this.data = {"products":[{"name":"car","product":[{"name":"honda","model":[{"id":"civic","name":"civic"},{"id":"accord","name":"accord"},{"id":"crv","name":"crv"},{"id":"pilot","name":"pilot"},{"id":"odyssey","name":"odyssey"}]}]}]}
}
}
Note : For better styling, add below line to your main style.css file
@import "~jsoneditor/dist/jsoneditor.min.css";
Build it integrated with ReactiveForms:
this.form = this.fb.group({
myinput: [this.data]
});
<form [formGroup]="form" (submit)="submit()">
<json-editor [options]="editorOptions2" formControlName="myinput">
</json-editor>
</form>
Besides all the configuration options from the original jsoneditor, Angular Json Editor supports one additional option:
expandAll - to automatically expand all nodes upon json loaded with the data input.
If you have issue with the height of the component, you can try one of those solutions:
When you import CSS:
@import "~jsoneditor/dist/jsoneditor.min.css";
textarea.jsoneditor-text{min-height:350px;}
Or Customizing the CSS:
:host ::ng-deep json-editor,
:host ::ng-deep json-editor .jsoneditor,
:host ::ng-deep json-editor > div,
:host ::ng-deep json-editor jsoneditor-outer {
height: 500px;
}
Or as a inner style in component:
<json-editor class="col-md-12" #editorExample style="min-height: 300px;" [options]="editorOptionsData" [data]="dataStructure"></json-editor>
For code view you can change the height using this example:
.ace_editor.ace-jsoneditor {
min-height: 500px;
}
Use debug mode to see in your console the data and options passed to jsoneditor. Copy this and paste in your issue when reporting bugs.
<json-editor [debug]="true" [options]="editorOptionsData" [data]="dataStructure"></json-editor>
If you find youself trying to use an custom option that is not mapped here, you can do:
let editorOptions: JsonEditorOptions = new JsonEditorOptions(); (<any>this.editorOptions).templates = [{menu options objects as in json editor documentation}]
See the issue
If you want to support IE, please follow this guide:
To use multiple jsoneditors in your view you cannot use the same editor options.
You should have something like:
<div *ngFor="let prd of data.products" class="w-100-p p-24" >
<json-editor [options]="makeOptions()" [data]="prd" (change)="showJson($event)"></json-editor>
</div>
makeOptions = () => {
return new JsonEditorOptions();
}
Demo component files are included in Git Project.
Demo Project with a lot of different implementations (ngInit, change event and others): [https://github.com/mariohmol/ang-jsoneditor/tree/master/src/app/demo)
When publishing it to npm, look over this docs: https://docs.npmjs.com/misc/developers
Fork, clone this repo and install dependencies:
npm i -g rimraf
npm i
MIT(./LICENSE)
FAQs
[](https://travis-ci.org/mariohmol/ang-jsoneditor)
The npm package @opsystech/ang-jsoneditor receives a total of 1 weekly downloads. As such, @opsystech/ang-jsoneditor popularity was classified as not popular.
We found that @opsystech/ang-jsoneditor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.