├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── LICENSE.md ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── App.test.tsx ├── App.tsx ├── index.css ├── index.tsx ├── pages │ └── home.tsx ├── react-app-env.d.ts ├── reportWebVitals.ts ├── service-worker.ts ├── serviceWorkerRegistration.ts └── setupTests.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules 3 | dist 4 | cert 5 | get_env.js -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | parser: '@typescript-eslint/parser', 7 | plugins: [ 8 | '@typescript-eslint', 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | // 'plugin:@typescript-eslint/eslint-recommended', 13 | 'plugin:@typescript-eslint/recommended', 14 | ], 15 | rules: { 16 | '@typescript-eslint/naming-convention': [ 17 | 'error', 18 | { 19 | 'selector': 'variable', 20 | 'format': ['camelCase', 'UPPER_CASE', 'PascalCase'], 21 | 'leadingUnderscore': 'allow' 22 | }, 23 | { 24 | 'selector': 'typeLike', 25 | 'format': ['PascalCase'] 26 | } 27 | ], 28 | '@typescript-eslint/indent': [ 29 | 'error', 30 | 2 31 | ], 32 | '@typescript-eslint/prefer-namespace-keyword': 'error', 33 | '@typescript-eslint/quotes': [ 34 | 'error', 35 | 'single', 36 | { 37 | 'avoidEscape': true 38 | } 39 | ], 40 | '@typescript-eslint/semi': [ 41 | 'error', 42 | 'never' 43 | ], 44 | '@typescript-eslint/type-annotation-spacing': 'error', 45 | '@typescript-eslint/member-delimiter-style': [ 46 | 'error', 47 | { 48 | 'multiline': { 49 | 'delimiter': 'comma', 50 | 'requireLast': false 51 | }, 52 | 'singleline': { 53 | 'delimiter': 'comma', 54 | 'requireLast': false 55 | } 56 | } 57 | ], 58 | '@typescript-eslint/no-unused-vars': [ 59 | 'warn', 60 | { 61 | 'vars': 'all', 62 | 'args': 'all', 63 | 'varsIgnorePattern': '^\_.*$', 64 | 'argsIgnorePattern': '^\_.*$', 65 | } 66 | ], 67 | '@typescript-eslint/no-extra-parens': 'error', 68 | '@typescript-eslint/brace-style': 'error', 69 | '@typescript-eslint/no-use-before-define': 'off', 70 | '@typescript-eslint/no-explicit-any': 'off', 71 | '@typescript-eslint/explicit-function-return-type': 'off', 72 | '@typescript-eslint/no-namespace': 'off', 73 | '@typescript-eslint/no-inferrable-types': 'off', 74 | '@typescript-eslint/no-empty-function': 'off', 75 | '@typescript-eslint/no-empty-interface': 'off', 76 | 'no-null/no-null': 'off', 77 | 'no-useless-escape': 'off', 78 | 'no-trailing-spaces': 'error', 79 | 'no-var': 'error', 80 | 'prefer-const': 'error', 81 | 'spaced-comment': 'error', 82 | 'object-curly-spacing': ['error', 'always'], 83 | 'space-in-parens': ['error', 'never'], 84 | 'array-bracket-spacing': ['error', 'never'], 85 | 'space-before-function-paren': [ 86 | 'error', 87 | { 88 | 'named': 'never', 89 | 'anonymous': 'always', 90 | 'asyncArrow': 'always' 91 | } 92 | ], 93 | '@typescript-eslint/no-var-requires': 'off' 94 | } 95 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 M Gilang Januar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![vercel](https://www.datocms-assets.com/31049/1618983297-powered-by-vercel.svg)](https://vercel.com/?utm_source=restfire-studio&utm_campaign=oss) 2 | 3 | # Repair JSON 4 | 5 | Fixing the shitty JSON string from logs or etc. Already run and deployed at Vercel http://repair-json.vercel.app/ 6 | 7 | ## Getting Started 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode. 12 | Open http://localhost:3000 to view it in the browser. 13 | 14 | The page will reload if you make edits. 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn build` 18 | 19 | Builds the app for production to the build folder. 20 | It correctly bundles React in production mode and optimizes the build for the best performance. 21 | 22 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 23 | 24 | ## Contributing 25 | 26 | 0. Like this repo <3 27 | 0. Send an issue 28 | 0. Or, fork and send us a pull request to `master` branch 29 | 30 | ## License 31 | 32 | [MIT](./LICENSE.md) 33 | 34 | ![high-five](https://media0.giphy.com/media/26BREWfA5cRZJbMd2/giphy.gif?cid=ecf05e4721370e49dc41cdc59e140f4c0337fcaa46553ddb&rid=giphy.gif) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "repair-json", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.4", 7 | "@testing-library/react": "^11.1.0", 8 | "@testing-library/user-event": "^12.1.10", 9 | "@types/jest": "^26.0.15", 10 | "@types/node": "^12.0.0", 11 | "@types/react": "^17.0.0", 12 | "@types/react-dom": "^17.0.0", 13 | "antd": "^4.16.1", 14 | "dirty-json": "^0.9.2", 15 | "react": "^17.0.2", 16 | "react-dom": "^17.0.2", 17 | "react-json-view": "^1.21.3", 18 | "react-router-dom": "^5.2.0", 19 | "react-scripts": "4.0.3", 20 | "typescript": "^4.1.2", 21 | "web-vitals": "^1.0.1", 22 | "workbox-background-sync": "^6.1.5", 23 | "workbox-broadcast-update": "^6.1.5", 24 | "workbox-cacheable-response": "^6.1.5", 25 | "workbox-core": "^6.1.5", 26 | "workbox-expiration": "^6.1.5", 27 | "workbox-google-analytics": "^6.1.5", 28 | "workbox-navigation-preload": "^6.1.5", 29 | "workbox-precaching": "^6.1.5", 30 | "workbox-range-requests": "^6.1.5", 31 | "workbox-routing": "^6.1.5", 32 | "workbox-strategies": "^6.1.5", 33 | "workbox-streams": "^6.1.5" 34 | }, 35 | "scripts": { 36 | "start": "react-scripts start", 37 | "build": "react-scripts build", 38 | "test": "react-scripts test", 39 | "eject": "react-scripts eject" 40 | }, 41 | "eslintConfig": { 42 | "extends": [ 43 | "react-app", 44 | "react-app/jest" 45 | ] 46 | }, 47 | "browserslist": { 48 | "production": [ 49 | ">0.2%", 50 | "not dead", 51 | "not op_mini all" 52 | ], 53 | "development": [ 54 | "last 1 chrome version", 55 | "last 1 firefox version", 56 | "last 1 safari version" 57 | ] 58 | }, 59 | "devDependencies": { 60 | "@types/react-router-dom": "^5.1.7" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgilangjanuar/repair-json/721bbe87053a26d93e64bbe41f7309b7815581d3/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | Repair JSON 28 | 29 | 36 | 37 | 38 | 39 | 40 |
41 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgilangjanuar/repair-json/721bbe87053a26d93e64bbe41f7309b7815581d3/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgilangjanuar/repair-json/721bbe87053a26d93e64bbe41f7309b7815581d3/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Repair JSON", 3 | "name": "Fixing the shitty JSON string from logs or etc", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#000000" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { render, screen } from '@testing-library/react' 3 | import App from './App' 4 | 5 | test('renders learn react link', () => { 6 | render() 7 | const linkElement = screen.getByText(/learn react/i) 8 | expect(linkElement).toBeInTheDocument() 9 | }) 10 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import { GithubOutlined, HomeOutlined, MenuFoldOutlined, MenuUnfoldOutlined, CoffeeOutlined } from '@ant-design/icons' 2 | import { Divider, Layout, Menu, Typography } from 'antd' 3 | import 'antd/dist/antd.dark.min.css' 4 | import React, { useState } from 'react' 5 | import Home from './pages/home' 6 | 7 | 8 | 9 | function App(): React.ReactElement { 10 | const [collapsed, setCollapsed] = useState() 11 | 12 | return ( 13 | 14 | setCollapsed(col)} breakpoint="lg" collapsedWidth="0" trigger={null} collapsible collapsed={collapsed} style={{ minHeight: '100vh' }}> 15 | 16 | }>Home 17 | }>GitHub 18 | }>Donate 19 | 20 | 21 | 22 | {/* 23 | setCollapsed(!collapsed)}>{ collapsed ? : } 24 | */} 25 | 26 |

27 | setCollapsed(!collapsed)}>{ collapsed ? : } 28 |

29 | 30 |
31 | 32 | 33 | 34 | Repair JSON © 2021 35 | 36 | 37 | 38 | Powered by Vercel 39 | 40 | 41 | 42 |
43 |
44 | ) 45 | } 46 | 47 | export default App 48 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import App from './App' 4 | import * as serviceWorkerRegistration from './serviceWorkerRegistration' 5 | import reportWebVitals from './reportWebVitals' 6 | import './index.css' 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , 12 | document.getElementById('root') 13 | ) 14 | 15 | // If you want your app to work offline and load faster, you can change 16 | // unregister() to register() below. Note this comes with some pitfalls. 17 | // Learn more about service workers: https://cra.link/PWA 18 | serviceWorkerRegistration.register() 19 | 20 | // If you want to start measuring performance in your app, pass a function 21 | // to log results (for example: reportWebVitals(console.log)) 22 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 23 | reportWebVitals() -------------------------------------------------------------------------------- /src/pages/home.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Form, notification, Space, Switch, Typography } from 'antd' 2 | import { useForm } from 'antd/lib/form/Form' 3 | import TextArea from 'antd/lib/input/TextArea' 4 | import djson from 'dirty-json' 5 | import React, { useEffect, useState } from 'react' 6 | import ReactJson from 'react-json-view' 7 | 8 | 9 | const Home: React.FC = () => { 10 | const example = { 11 | object: { text: 'greeting :\n\t"halo"', from: '🤡 unknown', timestamp: 1406543845 }, 12 | string: '{"text":"greeting :\\n\\t"halo"" from: \'🤡 unknown\', timestamp: 01406543845' 13 | } 14 | const [form] = useForm() 15 | const [object, setObject] = useState(example.object) 16 | const [prettyView, setPrettyView] = useState(true) 17 | 18 | useEffect(() => { 19 | form.setFieldsValue({ 20 | json: example.string 21 | }) 22 | }, []) 23 | 24 | const onFixIt = async () => { 25 | const { json } = form.getFieldsValue() 26 | try { 27 | const data = djson.parse(json) 28 | if (typeof data !== 'object') { 29 | throw new Error('Data is not an object') 30 | } 31 | notification.success({ 32 | message: 'Yeay!', 33 | description: 'Scroll down to check your clean JSON' 34 | }) 35 | setObject(data) 36 | } catch (error) { 37 | notification.error({ 38 | message: 'Oh, shit!', 39 | description: error.message 40 | }) 41 | setObject({}) 42 | } 43 | } 44 | 45 | const clear = async () => { 46 | form.resetFields() 47 | setObject({}) 48 | } 49 | 50 | return ( 51 |
52 | 💩 Repair JSON 53 |
54 | 55 |