Compare commits

..
Author SHA1 Message Date
sharevb ebfae5e81c feat(new tools): JSON to PHP Array and reverse
Fix #804
2024-05-19 18:30:58 +02:00
12 changed files with 775 additions and 173 deletions

No files matched your search

+2 -7
View File
@@ -109,6 +109,7 @@ declare module '@vue/runtime-core' {
JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default']
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
JsonToPhpArray: typeof import('./src/tools/json-to-php-array/json-to-php-array.vue')['default']
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
@@ -130,21 +131,14 @@ declare module '@vue/runtime-core' {
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpin: typeof import('naive-ui')['NSpin']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
@@ -152,6 +146,7 @@ declare module '@vue/runtime-core' {
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
PhpArrayToJson: typeof import('./src/tools/php-array-to-json/php-array-to-json.vue')['default']
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
+2
View File
@@ -65,6 +65,7 @@
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"json5": "^2.2.3",
"jsonar-mod": "^1.9.0",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
@@ -86,6 +87,7 @@
"unicode-emoji-json": "^0.4.0",
"unplugin-auto-import": "^0.16.4",
"uuid": "^9.0.0",
"vite-plugin-node-polyfills": "^0.21.0",
"vue": "^3.3.4",
"vue-i18n": "^9.9.1",
"vue-router": "^4.1.6",
+662 -88
View File
File diff suppressed because it is too large. Load diff
+4 -2
View File
@@ -1,7 +1,8 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as maliciousLinksTester } from './malicious-links-tester';
import { tool as jsonToPhpArray } from './json-to-php-array';
import { tool as phpArrayToJson } from './php-array-to-json';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -129,7 +130,8 @@ export const toolsByCategory: ToolCategory[] = [
httpStatusCodes,
jsonDiff,
safelinkDecoder,
maliciousLinksTester,
jsonToPhpArray,
phpArrayToJson,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { BrandPhp } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Json to PHP-Array',
path: '/json-to-php-array',
description: 'Convert JSON to PHP Array',
keywords: ['json', 'php', 'array'],
component: () => import('./json-to-php-array.vue'),
icon: BrandPhp,
createdAt: new Date('2024-05-11'),
});
@@ -0,0 +1,36 @@
<script setup lang="ts">
import jsonar from 'jsonar-mod';
import JSON5 from 'json5';
import type { UseValidationRule } from '@/composable/validation';
import { withDefaultOnError } from '@/utils/defaults';
const defaultValue = `{
a:"b",
arr: [1, "2"],
nested: {
c:12,
d: "az"
}
}`;
function transformer(value: string) {
return withDefaultOnError(() => jsonar.arrify(JSON5.parse(value), { prettify: true }), '');
}
const rules: UseValidationRule<string>[] = [
{
validator: (v: string) => JSON5.parse(v),
message: 'Provided JSON is not valid.',
},
];
</script>
<template>
<format-transformer
input-label="Your JSON"
:input-default="defaultValue"
input-placeholder="Paste your JSON here..."
output-label="PHP Array version"
:input-validation-rules="rules"
:transformer="transformer"
/>
</template>
+4
View File
@@ -0,0 +1,4 @@
declare module 'jsonar-mod' {
export function arrify(json: any, options?: { prettify?: boolean}): string
export function parse(php: string): object
}
@@ -1,12 +0,0 @@
import { ShieldCheck } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Malicious Links Checker',
path: '/malicious-links-checker',
description: 'Check an url against Google Safe Browsing service',
keywords: ['malicious', 'links', 'checker', 'check', 'safe', 'safe-browsing', 'google'],
component: () => import('./malicious-links-checker.vue'),
icon: ShieldCheck,
createdAt: new Date('2024-05-11'),
});
@@ -1,64 +0,0 @@
<script setup lang="ts">
import { request } from 'malicious-link-detector';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
/*
What tool do you want?
Send Message via Whatsapp Web
Describe the solution you'd like
I would like to have an input field where I can write a mobile number and a textfield, where I can send a message.
A button "Send" which will open the follwowing url:
https://web.whatsapp.com/send/?phone=THE_MOBILE_NUMBER&text=THE_MESSAGE
it is important that the number is formatted correctly:
the "0" at the beginning should be "49" (for germany) and all spaces or characters like "-" should be removed.
*/
const url = useQueryParam({ name: 'url', defaultValue: '' });
const urlValidation = useValidation({
source: url,
rules: [
{
message: 'Invalid url string',
validator: (value) => {
try {
const _ = (new URL(value));
return true;
}
catch {
return false;
}
},
},
],
});
const result = computedAsync(async () => {
const urlValue = url.value;
return await request(urlValue);
});
</script>
<template>
<div>
<c-input-text
v-model:value="url"
label="Website url"
placeholder="Put your website url here..."
clearable
mb-2
:validation="urlValidation"
/>
<c-alert v-if="result !== 'Safe'" type="error">
Danger! '{{ url }}' website is listed as not safe by Google Safe Browsing: <strong>{{ result }}</strong>
<c-alert />
</c-alert>
<c-alert v-if="result" type="success">
This website is safe.
<c-alert />
</c-alert>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { BrandPhp } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'PHP-Array to JSON',
path: '/php-array-to-json',
description: 'Convert PHP Array to JSON',
keywords: ['php', 'array', 'json'],
component: () => import('./php-array-to-json.vue'),
icon: BrandPhp,
createdAt: new Date('2024-05-11'),
});
@@ -0,0 +1,39 @@
<script setup lang="ts">
import jsonar from 'jsonar-mod';
import type { UseValidationRule } from '@/composable/validation';
import { withDefaultOnError } from '@/utils/defaults';
const defaultValue = `array(
"a" => "b",
"arr" => array(
1,
"2"
),
"nested" => array(
"c" => 12,
"d" => "az"
)
);`;
function transformer(value: string) {
return withDefaultOnError(() => JSON.stringify(jsonar.parse(value), null, 2), '');
}
const rules: UseValidationRule<string>[] = [
{
validator: (v: string) => v === '' || jsonar.parse(v),
message: 'Provided PHP Array is not valid.',
},
];
</script>
<template>
<format-transformer
input-label="Your PHP Array"
:input-default="defaultValue"
input-placeholder="Paste your PHP Array here..."
output-label="JSON version"
output-language="json"
:input-validation-rules="rules"
:transformer="transformer"
/>
</template>
+2
View File
@@ -1,5 +1,6 @@
import { resolve } from 'node:path';
import { URL, fileURLToPath } from 'node:url';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
import vue from '@vitejs/plugin-vue';
@@ -97,6 +98,7 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {